/ Published in: C#
How to use :
Compile and then run in your command line with some number parameter you want to check = PrimeNumber 1 3 5 10
Compile and then run in your command line with some number parameter you want to check = PrimeNumber 1 3 5 10
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; } }