读书人

Problem 七

发布时间: 2012-11-20 09:55:43 作者: rapoo

Problem 7
问题描述:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10001st prime number?



public static boolean IsPrime(long number) {int begin = 2;int end = (int) Math.sqrt(number) + 1;for (int i = begin; i < end; i++) {if (number % i == 0)return false;}return true;}public static long count(int number){long result = 1;int n = 0;long cur = 2;while(n<number){if(IsPrime(cur)){result = cur;n++;}cur++;}return result;}

读书人网 >编程

热点推荐