Ive looked up on this warning, but i dont really understand what is being explained in the code. This warning comes up but the console window comes up. Also the console window does not display anything. I think it might have something to do when I assign 'result to primeFactor % num.' (because primeFactor is along long int whilst return is just int). What i want the code to do is find the lowest factor of primeFactor. So I made a loop which continuously tests if the remainder is 0 then displays num. (So it finds what number divides evenly into primeFactor. Anyway here is my code:
#include < iostream>
//Foward declaration of function used to find the remainder
int findRemainder(int x, int y)
return x % y;
for(int num = 2; num < 100; num++)
longlongint primeFactor = 600851475143;
int result = findRemainder(primeFactor, num);
if (result = 0)
cout << num;
return 0 ;
NOTE: I know that primeFactor isnt prime. (ill fix it later.)
However, this code is not correct: if (result = 0)
That's because the assignment operator = is used rather than the comparison operator ==.
The reason why it is a warning, rather than an error is because the code is valid, and it's possible that it might have been deliberate. But I'm just about certain that in this case it wasn't deliberate, and thus really is an error.