// con1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; int main() { int n, numDiv = 0, i; cout << "Enter an int "; cin >> n; for (i = 1; i <= n; i++) { if (n%i == 0) { numDiv++; if (numDiv >= 3) // I already know the number is not prime, break; // no point in checking the rest of i values } //... } if (numDiv == 2) cout << "prime" << endl; else cout << "Not prime" << endl; return 0; } /* i=1..n see if (n%i == 0) numDiv++? after loop, prime if numDiv==2 i=1..n same above, end loop if numDiv>2 same as above, i = 1..sqrt(n)+1 only check odd numebrs 982451653 */