-
Notifications
You must be signed in to change notification settings - Fork 18
/
Abundant Numbers.cs
44 lines (43 loc) · 1.15 KB
/
Abundant Numbers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication203
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Abundant Number:");
Console.WriteLine("\n");
Console.WriteLine("Enter the Number to be process");
int M = Convert.ToInt32(Console.ReadLine());
int i, n,sum=0;
n = M;
for (i = 1; i < n; i++)
{
if (M % i == 0)
{
sum = sum + i;
}
else
{
continue;
}
}
Console.WriteLine("\n");
Console.WriteLine("\n");
if (sum > M)
{
Console.WriteLine("The Given Number is {0} an Abundant Number ={1}",M,sum);
}
else
{
Console.WriteLine("The Abundant Number is not an Abundant Number");
}
Console.WriteLine("\n");
Console.ReadLine();
}
}
}