using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apps
{
class student
{
private int Sum = 0;
private int num1;
public student(int num)
{
num1 = num;
for (int i = 1; i <= num / 2; i++)
{
if (num % i == 0)
Sum += i;
}
if (Sum == num1)
{
Console.WriteLine("Entered number is perfect Number");
}
else
Console.WriteLine("Entered number is NOT perfect Number");
}
}
class PerFectNumber
{
static void Main()
{
Console.WriteLine("Enter a Number to check for a perfect Number");
int number = Int32.Parse(Console.ReadLine());
student s1 = new student(number);
}
}
}
No comments:
Post a Comment