文章目錄

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

Truncatable primes

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

Find the sum of the only eleven primes that are both truncatable from left to right and right to left.

NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.

可截断的素数

数3797有一个有趣的特性。它本身是素数,而且从左到右删除数字依然是素数:3797,797,97和7.类似的,从右到左也是这样:3797,379,37,和3.

求唯一的11个从左到右,从右到左都可截断的素数的和

注意:2,3,5,和7不认为是可截断的素数

解答:

这题没什么好说的。依然是筛法生成素数表,只是不知道素数到底会大到什么程度,所以写的有些丑陋。

打赏作者

文章目錄