Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9. setlocale(LC_ALL, "Rus");
  10.  
  11. int N;
  12.  
  13. int Sum;
  14.  
  15. cout << "Найдите все совершенные числа до N " << endl;
  16.  
  17. cout << "Введите число : " ;
  18.  
  19. cin >> N;
  20.  
  21. cout << " Совершенные числа :" << endl;
  22.  
  23. for (int i = 1; i <= N; i++)
  24.  
  25. {
  26.  
  27. Sum = 0;
  28.  
  29. for (int j = 1; j < i; j++)
  30.  
  31. {
  32.  
  33. if (i % j == 0)
  34.  
  35. {
  36.  
  37. Sum += j;
  38.  
  39. }
  40.  
  41. }
  42.  
  43. if (Sum == i)
  44.  
  45. {
  46.  
  47. cout << i << " " << endl;
  48.  
  49. }
  50.  
  51. }
  52.  
  53. return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement