Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 회귀
- Blasius
- heap
- 유체역학
- 디스크 컨트롤러
- Statistics
- Laminar
- 예제
- Finite Difference Method
- Heat Equation
- Navier-Stokes
- programmers
- Turbulent
- Python
- 힙
- python3
- Crank-Nicolson
- Boundary Layers
- Compressible Flow
- 우선순위큐
- 통계학
- projecteuler
- FTCS
- 파이썬
- regression
- Fluid Dynamics
- 프로젝트오일러
- 이중우선순위큐
- 프로그래머스
- Fluids
Archives
- Today
- Total
Sudal's Garage
Project Euler 10 본문
Question:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
문제:
10 이하의 소수들의 합은 2 + 3 + 5 + 7 = 17이다.
2백만 이하의 소수들의 총합을 구하여라.
Solution:
1 2 3 4 5 6 7 8 9 10 11 | from sympy import isprime import time i = 1 start = time.time() sum = 0 while i < 2e6: if isprime(i) == True: sum += i i += 1 print(sum) print('elapsed time: {}s'.format(time.time() - start)) | cs |
sympy 의 isprime 를 이용한 풀이
3.85 초 가량 걸렸다
1 2 3 4 5 6 | from sympy import primerange import time start = time.time() print(sum(primerange(1,int(2e6+1)))) print('elapsed time: {}s'.format(time.time() - start)) | cs |
3초 걸렸다
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 12 (0) | 2019.02.27 |
---|---|
Project Euler 11 (0) | 2019.02.26 |
Project Euler 9 (0) | 2019.02.06 |
Project Euler 8 (0) | 2019.02.05 |
Project Euler 6 (0) | 2019.01.30 |