SHARE
TWEET

Untitled

a guest Jan 17th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<string.h>
  4. #include<iostream>
  5. #include<vector>
  6. #include<string>
  7. using namespace std;
  8.  
  9. int a[1000006];
  10. int main(){
  11.     int t,n,i,j,u;
  12.     while(n!=0){
  13.         cin>>n;
  14.         int dem=0;
  15.         for(i=0;i<1000006;i++){
  16.             a[i]=1;
  17.             a[0]=0;
  18.             a[1]=0;        
  19.         }
  20.         for(i=2;i<1000006;i++){
  21.             for(j=i*2;j<1000006;j+=i){
  22.                 a[j]=0;
  23.             }
  24.         }      
  25.         for(i=n+1;i<=2*n;i++){
  26.             if(a[i]==1)
  27.                 dem++; 
  28.         }
  29.         cout<<dem<<endl;
  30.     }
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top