#include <iostream>
using namespace std;
long int math;
long int check;
long int divider = 1;
long int inputnum;
void dividerp();
void counter();
void inputp();
void dividerp(){
math = inputnum/divider;
if (math == 1 or inputnum == 2 or inputnum == 1){
cout<<"You do have a prime number there!"<<endl;
system("PAUSE");
system("CLS");
math = 0;
inputp();
}
else if (math == inputnum){
counter();
}
else if ( inputnum % divider != 0 ){
counter();
}
else if (math >= 1){
cout<<"You do not have a prime number!"<<endl;
system("PAUSE");
system("CLS");
math = 0;
inputp();
}
else{
counter();
}
}
void counter(){
divider = divider + 1;
dividerp();
}
void inputp(){
divider = 1;
cout<< "Please type in a number."<<endl;
cout<< "I will check to see if it is a prime number."<<endl;
cin>> inputnum;
if (inputnum >= 1){
dividerp();
}
else {
cout<<"Sorry you have not typed in an accurate number."<<endl;
system("PAUSE");
system("CLS");
inputnum = 0;
inputp();
}
}
int main(){
cout<< "Hello and welcome to the program."<<endl;
inputp();
}
I'm still learning, (Went back from allegrogl, totally forgot how to do this stuff) Is there a way to improve this code, or types of functions that can improve performance (Not like there is a problem with it). And how can I increase the number range that I can use to find more prime numbers? I can't use floats/doubles due to the fact that they for some reason do not like to have math applied to them, is there a way to fix that?
EDIT: Optimizing code, that's the word i'm looking for. How can I optimize code?