tooltiperror
Super Moderator
- Reaction score
- 231
I've been writing a function in C++ to see if something is prime. My first thought process was that you could check to see if something is composite by seeing if it was divisible by a number in a loop, and exit when the integer reaches the integer x, the argument. The problem is, I can't find out how to check if something is a whole number.
This is what I have so far (I am aware it's incomplete):
This is what I have so far (I am aware it's incomplete):
Code:
{
int y;
for (y=1; NULL; y++) {
if (x=1) {
//It is composite,
return 1; // so return 1.
}
} // If it isn't composite, it
return 0; // must be prime.
}