UVA 382 Perfection Solution
Solve In C:
#include<stdio.h>
int main()
{
long long int sum=0,i,j,n;
printf("PERFECTION OUTPUT\n");
while(scanf("%lld",&n)!=EOF)
{
sum=0;
if(n==0)
break;
for(j=1; j<=n/2; j++)
{
if(n%j==0)
sum=sum+j;
}
if(sum==n)
printf("%5lld PERFECT\n",sum);
else if(sum<n)
printf("%5lld DEFICIENT\n",n);
else
printf("%5lld ABUNDANT\n",n);
}
printf("END OF OUTPUT\n");
}
No comments