In this post i am going to depict how to print all the numbers in a given range divisible by a given number.
|Enter lower range limit: 2
Enter upper range limit:35
Enter the number to be divided by:3
In the above program the upper range and lower are taken from the user and are stored in the variables ‘a’ and ‘b’ respectively. We have taken an input number to be divided by from the user and is stored in ‘num’ variable. Using for loop we print all the factors of that divisible number. When the remainder of the number divided by is equal to 0, then ‘x’ is printed.
|Enter lower range limit:7
Enter upper range limit:40
Enter the number to be divided by:5
In case 2 test case we have given the lower limit 7 but the number to be divided by is 5. After the number 7 the next immediate factor of 5 is 10. Hence it prints from 10.