Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <math.h>
- using namespace std;
- int N = 100000;
- bool sito[100000];
- int silnia(int n)
- {
- int wynik = 1;
- if(n<2)
- {
- return 1;
- }
- for(int i=2; i<=n; i++)
- {
- wynik=wynik*i;
- }
- return wynik;
- }
- bool czyPierwsze(int n)
- {
- if(n<2)
- {
- return false;
- }
- for(int i=2; i<sqrt(n)+1; i++)
- {
- if(n%i==0)
- {
- return false;
- }
- }
- return true;
- }
- void przesiew()
- {
- for(int i=2; i<N; i++)
- {
- if(sito[i]==true)
- {
- for(int j=i+i; j<N; j+=i)
- {
- sito[j]= false;
- }
- }
- }
- }
- void wyczyscSito()
- {
- for(int i=2; i<N; i++)
- {
- sito[i] = true;
- }
- }
- void wypiszSito()
- {
- for(int i=0;i<N; i++)
- {
- cout<<sito[i]<<" ,";
- }
- }
- int main()
- {
- // int a;
- // cin>>a;
- wyczyscSito();
- przesiew();
- for(int i=0;i<N;i++)
- {
- if(sito[i]==true)
- {
- cout<<i<<" ,";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement