The problem with 74 can be fixed by first checking if the number is even.
The problem with 161 can be fixed with a break after printing the first value.
a (slighty) faster way would check if 2 is divisor, then start from i=3 to square root n inclusive, check if i is divisor, then add 2 to i (only check for odd i)
another (slighty) faster way would check for i=2, i=3, then start from i=5 to square root n inclusive, check if i and i+2 is/are divisor(s), then add 6 to i (only check for i = 6k-1 and i=6k+1)
and more faster if square root n is re-calculated everytime we find a divisor...