Skip to content

Commit

Permalink
1164 C
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPLopes committed Dec 19, 2019
1 parent a81078b commit ae97745
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions C/1164.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int isPerfect(int N)
{
int sum = 0;
for (int i = 1; i <= N / 2; i++)
{
if (N % i == 0)
{
sum += i;
}
}
return (N == sum ? 1 : 0);
}
void msg(int N, int isPerfect)
{
if (isPerfect == 1)
printf("%i eh perfeito\n", N);
else
printf("%i nao eh perfeito\n", N);
}

int main(int argc, char const *argv[])
{
int times, N, is;
scanf("%i", &times);

for (size_t i = 0; i < times; i++)
{
scanf("%i", &N);
is = 0;
is = isPerfect(N);
msg(N, is);
}

return 0;
}

0 comments on commit ae97745

Please sign in to comment.