일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Navier-Stokes
- 프로그래머스
- Python
- Finite Difference Method
- 프로젝트오일러
- Blasius
- projecteuler
- Crank-Nicolson
- Boundary Layers
- Statistics
- 예제
- 유체역학
- 이중우선순위큐
- programmers
- 회귀
- python3
- FTCS
- Laminar
- Compressible Flow
- 디스크 컨트롤러
- Heat Equation
- Fluid Dynamics
- Fluids
- 파이썬
- heap
- 통계학
- 힙
- regression
- 우선순위큐
- Turbulent
- Today
- Total
Sudal's Garage
Project Euler 45 본문
Question:
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...
Pentagonal Pn=n(3n−1)/2 1, 5, 12, 22, 35, ...
Hexagonal Hn=n(2n−1) 1, 6, 15, 28, 45, ...
It can be verified that T285 = P165 = H143 = 40755.
Find the next triangle number that is also pentagonal and hexagonal.
문제:
삼각수, 오각수, 육각수는 다음과 같은 공식들로 만들어진다.
Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...
Pentagonal Pn=n(3n−1)/2 1, 5, 12, 22, 35, ...
Hexagonal Hn=n(2n−1) 1, 6, 15, 28, 45, ...
우리는 T285 = P165 = H143 = 40755 임을 확인 할 수 있다.
40755 다음의 삼각수이면서 오각수이면서 육각수 인 수는 얼마인가?
Solution:
from math import sqrt def isTri(n): x = (sqrt(8*n + 1) - 1) / 2 return x == int(x) def isPenta(n): x = (sqrt(24*n + 1) + 1) / 6 return x == int(x) def isHexa(n): x = (sqrt(8*n + 1) + 1) / 4 return x == int(x) x = 286 while True: n = int((x * (x+1)) / 2) if isPenta(n) and isHexa(n): break x += 1 print('{}'.format(n))
삼각수 판별은 다음 글을 확인하자.
2019/04/03 - [Programming/Project Euler - python] - Project Euler 42
오각수 판별은 다음 글을 확인하자.
2019/04/05 - [Programming/Project Euler - python] - Project Euler 44
다음은 육각수 판별법이다. 출처: https://en.wikipedia.org/wiki/Hexagonal_number
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 44 (0) | 2019.04.06 |
---|---|
Project Euler 43 (0) | 2019.04.05 |
Project Euler 42 (0) | 2019.04.04 |
Project Euler 41 (0) | 2019.04.03 |
Project Euler 40 (0) | 2019.04.02 |