Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool Prim(int x){
- int d;
- if(x==1) return false;
- if(x == 2) return true;
- if(x%2==0) return false;
- for(d = 3; d*d <= x; d+=2)
- if(x%d==0)
- return false;
- return true;
- }
- int main()
- {
- int n, i;
- int k, a1, an;
- int contor = 1;
- cin>>n;
- if(n == 1)
- cout<<"1";
- while(contor <= n)
- {
- for(i = 2; i <= n; i ++){
- k = 1;
- if(Prim(i) == true)
- {
- an = a1 + 2;
- contor++;
- a1 = an;
- }
- else {
- for(int a = 2; a <= i; a++)
- if(i % a == 0)
- k++;
- an = a1 + k;
- contor++;
- a1 = an;
- }
- }
- }
- cout<<an;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement