UVa 382 - Perfection

#include<stdio.h>
int main()
{
    printf("PERFECTION OUTPUT\n");
    int sum,s1,j,a;
 
    while(scanf("%d",&a)==1)
    {
        if(a==0)
        {
            printf("END OF OUTPUT\n");
            break;
        }
        sum=0;
        for(j=1; j<=a/2; j++)
        {
            if(a%j==0)
            {
                sum+=j;
            }
        }
        if(sum==a)
            printf("%5d  PERFECT\n",a);
        else if(sum>a)
            printf("%5d  ABUNDANT\n",a);
        else if(sum<a)
            printf("%5d  DEFICIENT\n",a);
    }
    return 0;
}
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 মন্তব্য(গুলি):

একটি মন্তব্য পোস্ট করুন