数学方法: Saying that a number contains 1000 digits is the same as saying that it's greater than 10**999. The nth Fibonacci number is [phi**n / sqrt(5)], where the brackets denote "nearest integer". So we need phi**n/sqrt(5) > 10**999 n * log(phi…
题意:在斐波那契数列( 1 ,1,2,3,5 ...... )中,第一个有1000位数字的是第几项? 思路:滚动数组 + 大数加法 /************************************************************************* > File Name: euler025.c > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017…
Highly divisible triangular number Problem 12 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,…
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that…
题意:求出100!的各位数字和. /************************************************************************* > File Name: euler020.c > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017年06月28日 星期三 11时46分46秒 ***************************…
题意: 215 = 32768,而32768的各位数字之和是 3 + 2 + 7 + 6 + 8 = 26. 21000的各位数字之和是多少? 思路:大数乘法,计算 210 × 100 可加速计算,每次超过1000进位 /************************************************************************* > File Name: euler016.c > Author: WArobot > Blog: http://www.…
题目链接: https://projecteuler.net/problem=435 题意: The Fibonacci numbers $ {f_n, n ≥ 0}$ are defined recursively as \(f_n = f_{n-1} + f_{n-2}\) with base cases \(f_0 = 0\) and \(f_1 = 1\). Define the polynomials $ {F_n, n ≥ 0} $ as $F_n(x) =\sum_{i=0}^{n…
通过替换*3这样一个两位数的第一位,我们可以发现形成的九个数字有六个是质数,即13, 23,43,53,73,83.类似的,如果我们用同样的数字替换56**3这样一个五位数的第三位和第四位,会生成56003, 56113, 56333, 56443, 56663, 56773, 56993七个质数,事实是56003是拥有这个性质的最小质数.已知对于一个质数,可以通过使用相同的数字替换这个质数的一部分(不一定是相邻的数位),可以生成八个质数,求满足这个条件的最小质数. 分析:欧拉工程的前五十题都是…
一个古戈尔也就是\(10^{100}\)是一个天文数字,一后面跟着一百个零.\(100^{100}\)更是难以想像的大,一后面跟着两百个零.但是尽管这个数字很大,它们各位数字的和却只等于一.考虑两个自然数\(a,b\)形成的指数\(a^b(a,b<100)\),其最大的各位数字之和是多少? 分析:此题思路比较直接,暴力求解即可.在题目给它的范围内,\(a^b\)可以形成9801个数,计算这些数,求其各位数之和并返回其最大值,即为题目所求. # time cost = 190 ms ± 515 µ…
五位数\(16807=7^5\)也是一个五次幂,同样的,九位数\(134217728=8^9\)也是一个九次幂.求有多少个\(n\)位正整数同时也是\(n\)次幂? 分析:设题目要求的幂的底为\(n\),指数为\(k\),则这个幂应为\(k\)位数,则有: \[ 10^{k-1}<n^k<10^k \Rightarrow k-1<k\cdot log_{10}n<k \] 因为\(k\ge1\),则对于不等式\(k\cdot log_{10}n<k\),有\(log_{10}…