Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define TRUE 1
- #define FALSE 0
- int PARFAIT(int n)
- {
- int somme,diviseur;
- somme=1;
- for(diviseur = 2; diviseur <= n/2; diviseur++)
- {
- if(n%diviseur==0) somme=somme+diviseur;
- }
- if(n==somme) {return TRUE;} else {return FALSE;}
- return somme;
- }
- int main()
- {
- int n;
- printf("Veuillez entrer le nombre n ");
- scanf("%d",&n);
- if (n==0) printf("le nombre zero (0) n'est pas parfait \n");
- else
- {
- if (PARFAIT(n) == 1) printf("le nombre %d est parfait\n", n) else printf("le nombre %d n'est pas parfait\n", n);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement