文章目錄

原题链接 http://projecteuler.net/problem=12

Highly divisible triangular number

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,28
We 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?

三角数序列是由自然数相加形成的。第七个三角数是 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.前十个三角数是:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …

我们列举出前7个三角形数的因子:

1: 1

3: 1,3

6: 1,2,3,6

10: 1,2,5,10

15: 1,3,5,10

21: 1,3,7,21

28: 1,2,4,7,14,28

我们可以看到28是第一个有超过5个因子的三角数

求第一个超过500个因子的三角数

解答:

这题的题意其实就是求素数因子,将三角数表示成素数因子乘积的形式,如 (28 = 2^2 * 7),这里素数因子2的次数的取值为0,1,2三种可能,素数因子7的次数的取值为0,1两种可能,所以28的因子有6个。按照这个思路,去做就可以了。

打赏作者

文章目錄