From 739a31468fe9f051dd963738439948feb98ae362 Mon Sep 17 00:00:00 2001 From: goksunonal <32015340+goksunonal@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:16:10 +0300 Subject: [PATCH] Creating 10001. Prime Number Solution For java --- 007/PrimeOFThousand.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 007/PrimeOFThousand.java diff --git a/007/PrimeOFThousand.java b/007/PrimeOFThousand.java new file mode 100644 index 0000000..88c1064 --- /dev/null +++ b/007/PrimeOFThousand.java @@ -0,0 +1,28 @@ +import java.math.*; +public class PrimeOFThousand { + public static boolean isPrime(long number) { + long sqr=(long)Math.sqrt(number); + for(long i=2;i<=sqr;i++) { + if (number%i==0) { + return false; + } + + } + return true; + } + public static void main(String[] args) { + long count=0; + for(long i=2;;i++) { + if (i==2) { + count+=1; + }else if(isPrime(i)) { + count+=1; + } + if (count==10001) { + System.out.println(i); + break; + + } + } + } +}