#include using namespace std; void prime(int input) // takes the number you enter, and shows all integers up to it // and says if they're even, odd, or odd and prime { for (int n=10; n<=input; n++) // n = 10, it increases till it's equal to input { while (n%2==0) // tests for even number. if it's even, it's not going to be prime. // 2 is indeed prime, but n starts at 10 n_n { cout << n << " is even" << endl; break; } while (n%2!=0) // tests for odd number. if it's odd, there's a chance it's prime. { cout << n << " is odd "; // if it's odd, say so if ((n%3!=0)&&(n%4!=0)&&(n%5!=0)&&(n%6!=0)&&(n%7!=0)&&(n%8!=0)&&(n%9!=0)&&(n%10!=0)) // this big if statement is fullproof (as far as I can tell at this hour) // and will say it's prime if you can't divide 10 or anything lower into // it evenly. { cout << "and prime" << endl; break; // if it's prime, add that on to the odd part } else // if it's just odd, make a new line and start over { cout << endl; } break; } } } int main() { int input; cout << "Enter number: "; // gets a number from the user, prime() goes until this number cin >> input; if (input<11) // we want it to be at least 11 so it will pass the long "if" { cout << endl << "Higher than 10 please..." << endl; main(); // in case they enter 10 or below } prime(input); system("pause"); // so we can see the output without it closing immediately >_> }