Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- /// \file exercice3.cpp
- /// \author Mohamed El Amine Elforaïci(1769411), Si Da Li(1803407)
- /// \version Dernière entrée : 2016/02/13
- /// \since Création : 2016/02/13
- /// \Description Code qui affiche toutes les nombres entiers parfaits entre 1 et n
- ////////////////////////////////////////////////////////////////////////////////
- #include <cmath>
- #include <iostream>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- int main(){
- setlocale(LC_ALL, "");
- int nombrePlafond;
- int somme = 0;
- //int i = 0;
- int n = 1;
- cout << "Saisissez un nombre supérieur à 6: " << endl;
- cin >> nombrePlafond;
- for (int i = 6; i <= nombrePlafond; i++){
- while (n < i){
- if (i % n == 0){
- somme = somme + n;
- }
- n++;
- }
- if (somme == n)
- cout << i << " est un nombre parfait < " << nombrePlafond << endl;
- i++;
- system("pause");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement