1 min readApr 23, 2020
You don’t mention any header files at all in the C source, maybe the need for math.h should be pointed out. Also, the format code to print a long should be ld, not d.
The big problem for me was the shrinking loop. If the current value of n is used for the comparison, eventually one of the factors will be too large and the loop will end prematurely. When I tried your code, 7 wasn’t tested, but when I made the loop condition i<m and defined m as long m = ceil(sqrt(n)); it worked.