CSharp examples for System:Math Number
is Prime Number
using System;//from w ww. jav a2 s . c o m public class Main{ public static bool isPrime(long n) { long current = 2; var currentThreshold = n; if (n == 2) { return true; } while (current < currentThreshold) { if (n % current != 0) { currentThreshold = n / current; } else { return false; } current++; } return true; } public static bool isPrime(int n) { var current = 2; var currentThreshold = n; if (n == 2) { return true; } while (current < currentThreshold) { if (n % current != 0) { currentThreshold = n / current; } else { return false; } current++; } return true; } }