Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. bool Prim(int x){
  6. int d;
  7. if(x==1) return false;
  8. if(x == 2) return true;
  9. if(x%2==0) return false;
  10. for(d = 3; d*d <= x; d+=2)
  11. if(x%d==0)
  12. return false;
  13. return true;
  14. }
  15.  
  16. int main()
  17. {
  18. int n, i;
  19. int k, a1, an;
  20. int contor = 1;
  21. cin>>n;
  22. if(n == 1)
  23. cout<<"1";
  24. while(contor <= n)
  25. {
  26. for(i = 2; i <= n; i ++){
  27. k = 1;
  28. if(Prim(i) == true)
  29. {
  30. an = a1 + 2;
  31. contor++;
  32. a1 = an;
  33. }
  34. else {
  35. for(int a = 2; a <= i; a++)
  36. if(i % a == 0)
  37. k++;
  38. an = a1 + k;
  39. contor++;
  40. a1 = an;
  41. }
  42. }
  43. }
  44. cout<<an;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement