34 lines
644 B
C
34 lines
644 B
C
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
int main(int argc, char const *argv[])
|
||
|
|
{
|
||
|
|
while (1)
|
||
|
|
{
|
||
|
|
int input, sum = 0;
|
||
|
|
|
||
|
|
printf("Digite um número (digite -1 para sair):\n");
|
||
|
|
if (scanf("%d", &input) != 1) {
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (input < 0 ) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
for (int i = 1; i < input; i++)
|
||
|
|
{
|
||
|
|
if (input % i == 0) {
|
||
|
|
sum += i;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (sum == input) {
|
||
|
|
printf("%d é um número perfeito!\n", input);
|
||
|
|
} else {
|
||
|
|
printf("%d não é um número perfeito!\n", input);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|