일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 피타고라스 정리
- project euler
- 블록코딩
- 프로젝트 오일러
- 제곱근의뜻
- 하합
- algeomath
- 이항분포
- 작도
- 프랙탈
- 지오지브라
- 시뮬레이션
- java
- 큰 수의 법칙
- 삼각함수의그래프
- 정오각형
- 큰수의법칙
- 오일러
- 상합
- counting sunday
- python
- 몬테카를로
- 구분구적법
- 수학탐구
- 확률실험
- 리만합
- 알지오매스
- 파이썬
- 재귀함수
- Geogebra
Archives
- Today
- Total
이경수 선생님의 수학실험실
Problem 46(Goldbach's other conjecture) 본문
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 prime and twice a square.
\(9 = 7 + 2\times1^{2}\)
\(15 = 7 + 2 \times 2^{2}\)
\(21 = 3 + 2 \times 3^{2}\)
\(25 = 7 + 2 \times 3^{2}\)
\(27 = 19 + 2 \times 2^{2}\)
\(33 = 31 + 2 \times 1^{2}\)
It turns out that the conjecture was false.
What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
In Python:
import time
import math
def isprime(n):
if n == 0 or n == 1:
return False
else:
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
def issqaure(n):
if int(math.sqrt(n)) == math.sqrt(n):
return True
startTime = time.time()
i = 1
check = 0
primeList = [2]
while True:
check = 0
oddComposite = 2 * i + 1
if isprime(oddComposite):
primeList.append(oddComposite)
check = 1
else:
for prime in primeList:
if issqaure((oddComposite - prime) // 2):
check = 1
break
if check == 0:
print(oddComposite)
break
else:
i += 1
print(time.time() - startTime, "seconds")
Run time: 0.13228797912597656 seconds
Solution: 5777
'Project Euler' 카테고리의 다른 글
Problem 48(Self powers) (0) | 2019.08.16 |
---|---|
Problem 47(Distinct primes factors) (0) | 2019.08.15 |
Problem 45(Triangular, pentagonal, and hexagonal) (0) | 2019.08.15 |
Problem 44(Pentagon numbers) (0) | 2019.07.24 |
Problem 43(Sub-string divisibility) (0) | 2019.07.24 |
Comments