(Problem 7)10001st prime
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 10 001st prime number?
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h> int prim(int n)
{
int i;
for(i=; i*i<=n; i++)
{
if(n%i==)
return ;
}
return ;
} void solve(int n)
{
int i=;
int count=;
while()
{
if(prim(i))
{
count++;
if(count==n)
break;
}
i++;
}
printf("%d\n",i);
} int main()
{
int n=;
solve(n);
return ;
}
|
Answer:
|
25164150 |
(Problem 7)10001st prime的更多相关文章
- (Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- (Problem 3)Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...
- (Problem 49)Prime permutations
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...
- (Problem 70)Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...
- (Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
- (Problem 47)Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 7 15 = 3 5 The fi ...
- (Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- (Problem 35)Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...
- (Problem 73)Counting fractions in a range
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...
随机推荐
- python文件操作精髓
总是记不住API.昨晚写的时候用到了这些,但是没记住,于是就索性整理一下吧: python中对文件.文件夹(文件操作函数)的操作需要涉及到os模块和shutil模块. 得到当前工作目录,即当前Pyth ...
- MFC消息截获之pretranslatemessage
前几天,查了一个batch的问题,问题大致是这样,父窗口消息一个鼠标消息,弹出一个模态框,CPU负荷就飚升到100%(双核就是50%),非常怪异,用windbg,分析哪个线程占用CPU,定位到鼠标响应 ...
- jQuery 自学笔记—3
jQuery 语法实例 $(this).hide() 演示 jQuery hide() 函数,隐藏当前的 HTML 元素. $("#test").hide() 演示 jQuery ...
- 【Java】【Fulme】Flume-NG源代码阅读之SpoolDirectorySource
org.apache.flume.source.SpoolDirectorySource是flume的一个经常使用的source,这个源支持从磁盘中某目录获取文件数据.不同于其它异步源,这个源可以避免 ...
- ajax不执行success回调而是执行了error回调
最近在看jQuery的API文档,在使用到jQuery的ajax时,如果指定了dataType为json,老是不执行success回调,而是执行了error回调函数. 附上代码如下: JScrip ...
- input autocomplete 下拉提示+支持中文
js 代码: $.getJSON("/Foreign/Getforeign_routeEndPoint", function (data) { $(" ...
- 在GridView控件里面绑定DropDownList控件
参考链接: http://www.aspsnippets.com/Articles/Populate-DropDownList-with-Selected-Value-in-EditItemTempl ...
- 利用UICollectionView实现瀑布流
利用UICollectionView实现瀑布流通过自定义布局来实现. - 自定义类继承UICollectionViewLayout: 必须重写的方法有: //决定每个item的位置: - (nulla ...
- git和GItHub的区别
git是一个版本控制工具.github是一个用git做版本控制的项目托管平台. 这有点类似于Wordpress和Wordpress.com的关系,前者是一个任何人都可以用的免费博客系统,后者是一个平台 ...
- html 5 新增标签及简介
作为下一代Web技术的代表,HTML5概念在近些年尤其火热.据了解,HTML5受到垂青最直接的原因就是其跨平台性,除此之外,它不仅仅可以用于表示Web内容,还可能将Web带入一个广阔的生态平台. 下面 ...