projecteuler---->problem=7----10001st prime

title:

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?

翻译:

通过列出前6个质数,我们可知第6个质数是13。

那么第10001个质数是多少呢?

解答:

import math
# 试除法
def isOk(a):
	for i in range(2,int(math.sqrt(a))+1):
		if a%i == 0:
			return False
	return True
n=0
i=2
while n<10001:
	if isOk(i) :
		n+=1
	i += 1
print i-1

projecteuler---->problem=7----10001st prime

时间: 2024-10-06 20:10:55

projecteuler---->problem=7----10001st prime的相关文章

10001st prime

problem 7:10001st prime 题意:求第10001个质数 代码如下: 1 #ifndef PRO7_H_INCLUDED 2 #define PRO7_H_INCLUDED 3 4 #include "prime.h" 5 6 namespace pro7{ 7 int solve(){ 8 int p[200005]; 9 getPrime(200000,p); 10 return p[10000]; 11 } 12 } 13 14 #endif // PRO7_H

Project-Euler problem 1-50

最近闲的做了下Project Euler 上的题目,前面50题都比较简单,简单总结下.代码一般是Python和C/C++的 用Python 做这些题目简直是酸爽啊 一下代码可能不一定是我的,因为不知道论坛里面的回复不是永久的,所以我的代码有的丢了,可能找个和我的意思相近的代码.题目翻译是从 欧拉计划 | Project Euler 中文翻译站上面Copy 的表告我. Problem 1  Multiples of 3 and 5 10以下的自然数中,属于3和5的倍数的有3,5,6和9,它们之和是

[email&#160;protected] Sieve of Eratosthenes (素数筛选算法) &amp; Related Problem (Return two prime numbers )

Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example, if n is 10, the output should be “2, 3, 5, 7″. If n is 20, the output should be “2, 3, 5, 7, 11, 13,

Project Euler: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 once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? #include <iostream> #incl

Project Euler:Problem 50 Consecutive prime sum

The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds t

PE-7 10001st prime

package main import ( "fmt" "math" ) func main() { i := 2 num := 1 for num <= 10001 { if Prime(i) { num++ } i++ } fmt.Println(i - 1) } func Prime(num int) bool { if num == 2 || num == 3 { return true } if num%6 != 1 && num%6

Python练习题 035:Project Euler 007:第10001个素数

本题来自 Project Euler 第7题:https://projecteuler.net/problem=7 # Project Euler: 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? # Answer

欧拉计划(python) problem 7

10001st prime 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 10 001st prime number? python code : import math sqrt=math.sqrt def func(x): k=int(sqrt(x))+1 for i in range(2,k)

Project Euler Solution: Problem 3

Largest prime factor Problem 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? source link: https://projecteuler.net/problem=3 The time comlexity of my last solution is too large. I think

HDU 1319 Prime Cuts(打表)

Prime Cuts Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2171    Accepted Submission(s): 929 Problem Description A prime number is a counting number (1, 2, 3, ...) that is evenly divisible on