-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparfait.c
64 lines (57 loc) · 986 Bytes
/
parfait.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<math.h>
void numtest(float n);
void table(int n);
void nbparfait(int n);
int main(){
int choix,d;
float n;
while(n!=d){
printf("Veuillez entrer un nombre n=");
scanf("%f", &n);
numtest(n);
printf("Bienvenu dans ce programme\n");
printf("<<<menu>>>\n1-Table de multiplication\n2-Nombre parfait\n3-Quitter\n");
printf("Entrez votre choix\n");
scanf("%d", &choix);
if(choix==1){
printf("La table de multiplication par %f est:\n", n);
table(n);
}
else if(choix==2){
nbparfait(n);
}
else{
main;
}
}
return 0;
}
void numtest(float n){
int d;
d=(int)n;
if(d==n){
printf("Le nombre %f est entier\n", n);
}
}
void table(int n){
int i, produit;
for(i=0;i<=10;i++){
produit=n*i;
printf("%d*%d=%d\n", n, i, produit);
}
}
void nbparfait(int n){
int i, somme;
for(i=1;i<n;i++){
if(n%i==0){
somme+=i;
}
}
if(somme==n){
printf("Ce nombre est parfait\n");
}
else{
printf("nombre banal\n");
}
}