I want to create a program in C# 2005 which calculates prime factors of a given input. i want to use the basic and simplest things, no need to create a method for it nor arr
using static System.Console;
namespace CodeX
{
public class Program
{
public static void Main(string[] args)
{
for (int i = 0; i < 20; i++)
{
if (IsPrime(i))
{
Write($"{i} ");
}
}
}
private static bool IsPrime(int number)
{
if (number <= 1) return false; // prime numbers are greater than 1
for (int i = 2; i < number; i++)
{
// only if is not a product of two natural numbers
if (number % i == 0)
return false;
}
return true;
}
}
}