Created
July 25, 2015 07:16
-
-
Save MladenMladenov/844e78d421865be80521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
class PrimeCheckerMethod | |
{ | |
static bool PrimeChecker(long input) | |
{ | |
if (input < 2) | |
{ | |
return false; | |
} | |
else | |
{ | |
int divider = 2; | |
double maxDivider = Math.Sqrt(input); | |
while (divider <= maxDivider) | |
{ | |
if (input % divider == 0) | |
{ | |
return false; | |
} | |
divider++; | |
} | |
} | |
return true; | |
} | |
static void Main() | |
{ | |
long number = long.Parse(Console.ReadLine()); | |
Console.WriteLine("\"{0}\" is prime? {1}", number, PrimeChecker(number)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment