#include #include /*Author: Carl Staab Date: January 29, 1999 Description: It's a prime number tester. What else? Writes to screen*/ void factortester(int start, int finish); int main() { int start, finish; char answer; do { cout << "\fPrime Number Tester\n\n"; cout << "Enter the (positive) number to start testing at: "; cin >> start; cout << "Enter the (higher) number to finish testing at: "; cin >> finish; factortester(start, finish); cout << "\nWould you like to do it again? "; cin >> answer; }while (answer == 'Y' || answer == 'y'); return 0; } void factortester(int start, int finish) { int count, count_two, factor_exist = 0; for (count = start; count <= finish; count++) { for (count_two = floor(sqrt(count)); count_two > 0; count_two--) { if (count % count_two == 0) factor_exist++; } if (factor_exist <= 1) cout << count << " "; factor_exist = 0; } return; }