How it works...
This program finds the sum of sequence numbers from 1 up to the limit entered by the user. The user is asked to enter the limit, and the value entered by the user is assigned to the limit variable. For adding the sequence numbers, we will make use of a for loop. To do loop unrolling or to reduce the number of iterations of the loop, we find the integer by which the limit can be divided. That is, we divide the value in the limit variable by integers from 9 to 1. Once we get the integer by which the limit is divisible, we reduce the number of for loops by that integer.
Let's assume that the user enters a limit of 40, which is assigned to the limit variable. A for loop is set to run from the values 9 to 1, and every value from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access