일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- regression
- FTCS
- 예제
- heap
- projecteuler
- python3
- 디스크 컨트롤러
- Blasius
- Crank-Nicolson
- Statistics
- Python
- programmers
- 유체역학
- 프로젝트오일러
- 프로그래머스
- Heat Equation
- 파이썬
- Fluids
- Compressible Flow
- 우선순위큐
- Laminar
- Turbulent
- Finite Difference Method
- 회귀
- 통계학
- Boundary Layers
- Navier-Stokes
- 이중우선순위큐
- Fluid Dynamics
- 힙
- Today
- Total
Sudal's Garage
Project Euler 12 본문
Question:
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28We can see that 28 is the first triangle number to have over five divisors.
What is the value of the first triangle number to have over five hundred divisors?
문제:
삼각수는 자연수를 더해나가면서 만들 수 있다. 예를 들어 7번째 삼각수는 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28이다. 첫 번째 삼각수부터 열 번째 삼각수까지 나열하면 다음과 같다.
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
이제 각 삼각수의 약수들을 적어보자.
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,2약수의 개수가 처음으로 5개 보다 커지는 삼각수는 28이다.
그렇다면 약수의 개수가 처음으로 500개 보다 커지는 삼각수는?
Solution:
1 2 3 4 5 6 7 8 9 | from sympy import divisor_count i = 2 N = 1 while divisor_count(N) <= 500: N += i i += 1 print(N) | cs |
2019/01/29 - [Programming/python] - Module: sympy
Sympy 모듈에서 약수의 갯수를 카운팅 해주는 divisor_count method 를 이용
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 14 (0) | 2019.03.02 |
---|---|
Project Euler 13 (0) | 2019.02.28 |
Project Euler 11 (0) | 2019.02.26 |
Project Euler 10 (0) | 2019.02.16 |
Project Euler 9 (0) | 2019.02.06 |