/********************************************************** File: seq_prime.cc Description: A program that inputs an integer number and determines if it is a prime number or not sequentially. Author: Dana Vrajitoru Organization: IUSB Date: September 28, 2004 ***********************************************************/ #include using namespace std; #include int First_divisor(int n) { int sqroot = sqrt(n); cout << sqroot << endl; for (int i=2; i<=sqroot; i++) if (n % i == 0) return i; return 1; } int main() { int n; cout << "Enter a number" << endl; cin >> n; int d=First_divisor(n); if (d > 1) cout << n << " is not prime and has this divisor: " << d << endl; else cout << n << " is prime." << endl; } // 643876523 is prime