Prime Numbers (C++) – Not Working 100%

You probably need to turn on warnings in your compiler. The function f returns a bool (not an int as declared) and does not do so unless the number of divisors of x is equal to two. This are fairly trivial mistakes that any decent C++ compiler should warn you about. Do not ignore warnings.

Leave a Comment