Return to Snippet

Revision: 34887
at October 29, 2010 18:02 by indra


Initial Code
public class PrimeNumber
{

	public static void Main(string[] args)
	{
		for (int i = 0; i < args.Length; i++)
		{
			if (IsPrimeNumber(int.Parse(args[i])))
			{
				System.Console.WriteLine(args[i]);
			}
		}
	}

	public static bool IsPrimeNumber(int pNumber)
	{
		bool prime = true;

		for (int i = 2; i < pNumber; i++)
		{
			if (pNumber % i == 0)
			{
				prime = false;
			}
		}
		return prime;
	}
}

Initial URL

                                

Initial Description
How to use :

Compile and then run in your command line with some number parameter you want to check = PrimeNumber 1 3 5 10

Initial Title
Show prime number

Initial Tags

                                

Initial Language
C#