I'm trying to make a program where you enter the number you want to find primes up to which then lists all the primes up to that number... But I enter 100 then it just sits there... Here's my code so far:
#include <iostream>
#include <cmath>
int prime(int);
int main()
{
using namespace std;
int upto;
int current = 3;
cout << "Find primes up to: ";
cin >> upto;
while(current < upto){
cout << prime(current) << endl;
}
system("pause");
return 0;
}
int prime(int p)
{
int test = p - 1;
while(test > -1){
if(test == 0){
return p;
}
else if(test % p == 0){
return 0;
}
else
test - 1;
}
}