fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int prime[101];
  7. for(int i=0;i<101;i++)
  8. prime[i]=1;//As we dont know if a number is prime we assume that all numbers are prime and then we will mark all non primes
  9. prime[0]=0;
  10. prime[1]=0;
  11. //0 and 1 are not prime
  12. for(int i=2;i<11;i++)
  13. for(int j=2*i;j<101;j+=i)
  14. prime[j]=0;//Marking all multiples of i as not prime
  15. for(int i=2;i<101;i++)
  16. if(prime[i]==1)
  17. cout<<i<<endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 2740KB
stdin
Standard input is empty
stdout
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97