chapter5
This commit is contained in:
17
DeitelC/Chapter5/isPerfect.c
Normal file
17
DeitelC/Chapter5/isPerfect.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int isPerfect(int);
|
||||
|
||||
int isPerfect(int num) {
|
||||
int temp = 0;
|
||||
for(int i = 1; i < num; i++) {
|
||||
if(num % i == 0) {
|
||||
temp += i;
|
||||
}
|
||||
}
|
||||
if (temp == num) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user