일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 큰수의법칙
- 이항분포
- 재귀함수
- counting sunday
- 하합
- 큰 수의 법칙
- project euler
- 지오지브라
- 파이썬
- 정오각형
- Geogebra
- 피타고라스 정리
- 시뮬레이션
- 오일러
- 삼각함수의그래프
- 프랙탈
- 수학탐구
- algeomath
- 몬테카를로
- 확률실험
- 리만합
- python
- 블록코딩
- java
- 프로젝트 오일러
- 작도
- 상합
- 제곱근의뜻
- 구분구적법
- 알지오매스
Archives
- Today
- Total
이경수 선생님의 수학실험실
Problem 45(Triangular, pentagonal, and hexagonal) 본문
Problem 45(Triangular, pentagonal, and hexagonal)
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle | \(T_{n}=\frac{n(n+1)}{2}\) | 1, 3, 6, 10, 15, ... | ||
Pentagonal | \(P_{n}=\frac{n(3n-1)}{2}\) | 1, 5, 12, 22, 35, ... | ||
Hexagonal | \(H_{n}=n(2n-1)\) | 1, 6, 15, 28, 45, ... |
It can be verified that \(T_{285} = P_{165} = H_{143} = 40755\).
Find the next triangle number that is also pentagonal and hexagonal.
In Python:
import time
import math
def ispentagon(n):
if math.sqrt(1 + 24 * n) % 6 == 5:
return True
def ishexagon(n):
if math.sqrt(1 + 8 * n) % 4 == 3:
return True
startTime = time.time()
i = 286
while True:
trialge = i * (i + 1) // 2
if ispentagon(trialge) and ishexagon(trialge):
break
else:
i += 1
print(trialge)
print(time.time() - startTime, "seconds")
Run time: 0.05330491065979004 seconds
Solution: 1533776805
'Project Euler' 카테고리의 다른 글
Problem 47(Distinct primes factors) (0) | 2019.08.15 |
---|---|
Problem 46(Goldbach's other conjecture) (0) | 2019.08.15 |
Problem 44(Pentagon numbers) (0) | 2019.07.24 |
Problem 43(Sub-string divisibility) (0) | 2019.07.24 |
Problem 42(Coded triangle numbers) (0) | 2019.07.24 |
Comments