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
- Navier-Stokes
- 디스크 컨트롤러
- Python
- 이중우선순위큐
- 파이썬
- 프로젝트오일러
- FTCS
- 유체역학
- 우선순위큐
- Fluid Dynamics
- 예제
- Compressible Flow
- 회귀
- projecteuler
- Boundary Layers
- Heat Equation
- 통계학
- python3
- 힙
- programmers
- Statistics
- Blasius
- Finite Difference Method
- 프로그래머스
- Turbulent
- Crank-Nicolson
- heap
- Fluids
- regression
- Laminar
Archives
- Today
- Total
Sudal's Garage
Project Euler 34 본문
Question:
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
문제:
145는 '희한한 성질'이 있는 숫자인데, 1! + 4! + 5! = 1 + 24 + 120 = 145 와 같이 각 자리 숫자의 팩토리얼을 더하면 자기 자신이 된다.
이러한 '희한한 성질'이 있는 모든 숫자의 합을 구하여라.
주의: 1! = 1 이고 2! = 2 인데 이것들은 합이 아니므로 포함되지 않는다.
Solution:
from math import factorial import time result = list() start = time.time() for i in range(3,100000): summ = 0 for j in list(str(i)): summ += factorial(int(j)) if summ == i: result.append(i) print(sum(result)) print("Found in ...%.3fs" %(time.time() - start))
무난하다.
0.25 초 걸렸다!
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 36 (0) | 2019.03.29 |
---|---|
Project Euler 35 (0) | 2019.03.28 |
Project Euler 33 (0) | 2019.03.26 |
Project Euler 32 (0) | 2019.03.25 |
Project Euler 31 (0) | 2019.03.24 |