Project Euler 203
Project Euler 203
题目
Squarefree Binomial Coefficients
The binomial coefficients
1 | ||||||||||||||
1 | 1 | |||||||||||||
1 | 2 | 1 | ||||||||||||
1 | 3 | 3 | 1 | |||||||||||
1 | 4 | 6 | 4 | 1 | ||||||||||
1 | 5 | 10 | 10 | 5 | 1 | |||||||||
1 | 6 | 15 | 20 | 15 | 6 | 1 | ||||||||
1 | 7 | 21 | 35 | 35 | 21 | 7 | 1 | |||||||
... |
It can be seen that the first eight rows of Pascal's triangle contain
twelve distinct numbers:
A positive integer
Of the twelve distinct numbers in the first eight rows of Pascal's
triangle, all except
The sum of the distinct squarefree numbers in the first eight rows is
Find the sum of the distinct squarefree numbers in the first
解决方案
由于需要遍历的行数比较少,因此枚举出杨辉三角前
代码
1 | from tools import get_pascals_triangle, factorization |