首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Problem 七

2012-11-20 
Problem 7问题描述:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that t

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;}

热点排行