I want it to list prime numbers from 1 to 100 like this:
1. 1
2. 2
3. 3
4. 5
5. 7
etc.
#include <iostream>
using namespace std;
int main(){
int num = 1;
double number = 1;
double div = 1;
bool prime = true;
int top = 100;
while (number <= top){
while (div < number){
if (number / div == int(number / div)){
div++;
}
else {
prime = false;
}
}
if (prime == true){
cout << num << ". " << number << "\n";
num+=1;
}
number+=1;
div=0;
}
system("pause");
}
Please help. If there is some random code in there that makes no sense why its there, I probably put it there because I was trying anything to get it to work :P