Check The Given No Is Perfect Number ( ⇠Click On The Post For Best Page View)

Check The Given No. Is Perfect Number

In C#.Net Language

------------------------------------------------------------------------------------------------------------------ 

using System;

class Test
{
    public static void Main()
    {
        Console.WriteLine("enter the no");
         int no = Convert.ToInt32(Console.ReadLine());
        int rem = 0;
        int temp = no;
        for (int i = 1; i < no; i++)
        {
            if (no % i == 0)
            {
                rem = rem + i;
            }
        }
            if(rem==temp)
            {
                Console.WriteLine("given no is perfect no");
            }
            else
            {
                Console.WriteLine("not perffect no");
            }
       
    }
}

-----------------------------------------------------------------------------------------------------------------------------------

Comments

Popular posts from this blog

Mr. Myers wants to edit the marks assigned to the questions

Genral Ability

Object Orinted Programing