Skip to content

Commit ad66576

Browse files
authored
Create determining perfect number using functions
1 parent 7fee6ff commit ad66576

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
int func(int a){
3+
int sum=0;
4+
5+
for(int i=1;i<a;i++){
6+
if(a%i==0){
7+
8+
sum=sum+i;
9+
}
10+
11+
}
12+
13+
if(sum==a){
14+
printf("perfect");
15+
}
16+
else{
17+
printf(" not perfect");
18+
19+
}
20+
}
21+
22+
23+
int main()
24+
{
25+
26+
int n;
27+
printf("enter the number to find it is perfect or not : ");
28+
scanf("%d",&n);
29+
func(n);
30+
31+
32+
return 0;
33+
}

0 commit comments

Comments
 (0)