| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 큰수의법칙
- 재귀함수
- 피타고라스 정리
- java
- counting sunday
- 이항분포
- 확률실험
- algeomath
- 알지오매스
- 하합
- project euler
- 지오지브라
- 리만합
- 프랙탈
- 수학탐구
- 정오각형
- Geogebra
- 상합
- 파이썬
- 구분구적법
- 작도
- 블록코딩
- 제곱근의뜻
- 삼각함수의그래프
- python
- 큰 수의 법칙
- 프로젝트 오일러
- 시뮬레이션
- 오일러
- 몬테카를로
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