Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. /// \file exercice3.cpp
  3. /// \author Mohamed El Amine Elforaïci(1769411), Si Da Li(1803407)
  4. /// \version Dernière entrée : 2016/02/13
  5. /// \since Création : 2016/02/13
  6. /// \Description Code qui affiche toutes les nombres entiers parfaits entre 1 et n
  7. ////////////////////////////////////////////////////////////////////////////////
  8.  
  9. #include <cmath>
  10. #include <iostream>
  11. #include <clocale>
  12. #include <iomanip>
  13.  
  14. using namespace std;
  15. int main(){
  16. setlocale(LC_ALL, "");
  17.  
  18. int nombrePlafond;
  19. int somme = 0;
  20. //int i = 0;
  21. int n = 1;
  22. cout << "Saisissez un nombre supérieur à 6: " << endl;
  23. cin >> nombrePlafond;
  24. for (int i = 6; i <= nombrePlafond; i++){
  25. while (n < i){
  26. if (i % n == 0){
  27. somme = somme + n;
  28. }
  29. n++;
  30. }
  31. if (somme == n)
  32. cout << i << " est un nombre parfait < " << nombrePlafond << endl;
  33. i++;
  34. system("pause");
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement