This C# Program Displays the Factors of the Entered Number. The factors of a number are all those numbers that can divide evenly into the number with no remainder.
Example:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Project
{
class
className
{
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();
}
}
}
output looks like:
Enter the Number : 27 The Factors are : 1 3 9 27