programming-examples/c-sharp/Mathematics/C# Program to Display the Factors of the Entered Number.cs

37 lines
706 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Display the Factors of the Entered Number
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int num, x;
Console.WriteLine("Enter the Number ");
num = int.Parse(Console.ReadLine());
Console.WriteLine("The Factors are : ");
for (x = 1; x <= num; x++)
{
if (num % x == 0)
{
Console.WriteLine(x);
}
}
Console.ReadLine();
}
}
}
/*
Enter the Number : 27
The Factors are :
1
3
9
27