Even Fibonacci numbers
2014-03-07 07:20
369 查看
--Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: --1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... --By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. function list_iter() local n = 1000000 local i = 1 local j = 0 return function() if(i < n) then tmp = i + j j = i i = tmp return i end end end local sum = 0; for i in list_iter() do if(i % 2 == 0) then sum = sum + i end end print(sum)
相关文章推荐
- Even Fibonacci numbers
- 欧拉项目第二题 Even Fibonacci numbers
- PE 002 Even Fibonacci numbers
- Even Fibonacci numbers
- Project Euler Problem 2 - Even Fibonacci numbers
- 【欧拉计划2】Even Fibonacci numbers
- 欧拉计划---0002 Even Fibonacci numbers(四百万以内斐波纳契偶数和)
- 【欧拉计划2】Even Fibonacci numbers
- Problem 2 Even Fibonacci numbers (fibonacci 数学规律)
- Project Euler Problem 2: Even Fibonacci numbers
- [欧拉计划]Problem 2.Even Fibonacci numbers
- 【欧拉计划2】Even Fibonacci numbers
- Problem 2:Even Fibonacci numbers
- ProjectEuler编程之旅:2. Even Fibonacci numbers
- [projecteuler]Even Fibonacci numbers
- Project Euler 002 Even Fibonacci numbers
- 欧拉计划(2)Even Fibonacci numbers
- (Problem 2)Even Fibonacci numbers
- Project Euler 2 Even Fibonacci numbers
- PE2 Even Fibonacci numbers(最大菲波那列偶数)