Algorithm to find all the exact divisors of a given integer
First, your code should have the condition of i <= n/2, otherwise it can miss one of the factors, for example 6 will not be printed if n=12. Run the loop to the square root of the number (ie. i <= sqrt(n)) and print both i and n/i (both will be multiples of n). { … Read more