Quote Originally Posted by Valentas View Post
The program should print numbers whose factors sum up to prime numbers. However, there is something wrong with int primes(n) function.

I get into infinite loop and print statements show that p : 5 and divisor : 4 and it stays like that in that loop. I cannot find a flaw in my logic.
Use a debugger like gdb or what's built in to you IDE to step through loop, and verify what each variable each iteration. If you have a logic error, this will find it.