# include # include using namespace std; int main ( ) // // DIVISIBLE.CPP seeks a divisor for the input number N. // { int divisor; int n; int test; // // Initialize. // cout << "This program determines if a positive integer N is prime.\n"; cout << "Enter value of n: "; cin >> n; test = n - 1; divisor == 0; // // TEST is the number we are trying out. // If we ever succeed, we save the value in DIVISOR // and reset TEST to 1. // while ( 1 < test ) { if ( n % test == 0 ) { divisor = test; test = 1; } test = test - 1; } // // Report the results. // if ( divisor == 0 ) { cout << n << " is prime.\n"; } else { cout << n << " is divisible by " << divisor << ".\n"; } return 0; }