002. 斐波那契数列中的偶数
来源:互联网 发布:昆山远洋数据招聘信息 编辑:程序博客网 时间:2024/06/08 17:36
Problem 2: Even Fibonacci numbers
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.
斐波那契数列中的每一项被定义为前两项之和。要求找出该数列中值为不超过 4 百万的偶数的项之和。
我的python代码:
first = 1last =2 sum = 2while 1 : last = first + last; first = last - first; if last<4000000 : if last%2==0: sum+=last else: break;print sum
你知道有更好的可以留言啊,大家互相学习啊!
0 0
- 002. 斐波那契数列中的偶数
- 判断斐波那契数列中的某项是不是偶数
- Java 中的斐波那契数列
- 斐波那契数列偶数项求和(Project Euler Problem 2)
- 斐波那契数列数列计算
- 【LintCode】查找斐波那契数列中的N个数
- 斐波那契数列在C++中的实现
- 斐波那契数列在php中的简单实现
- 在斐波那契数列中,找出4百万以下的项中值为偶数的项之和。
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- 斐波那契数列
- C#中获取IP
- Android中webservice的简单使用以及使用handle在UI线程和子线程中传递数据
- java设计模式之门面模式
- myeclipse2014 集成maven 遇到的问题,解决方案
- poj 1061 青蛙的约会(拓展欧几里德)
- 002. 斐波那契数列中的偶数
- exchange2003配置
- VC++屏蔽某个键
- hdu 1429 胜利大逃亡(续)
- 如何写出更好的Java代码
- 自定义 Layer 属性的动画
- socket通信——多角度控制LED灯亮灭
- ASP.NET MVC插件技术
- 古色传香