Even Fibonacci numbers

Problem 2

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.

Answer:

 def isEven(a):
if a%2 == 0:
return True
return False Max = 4000000 a = 0
b = 1
c = 0
count = 0
while True:
c = a + b
if(c > Max):
break
if isEven(c):
count += c
a = b
b = c print("the result is ", count)

最新文章

  1. 【php学习】array_map,array_walk,array_filter的区别
  2. ASP.NET MV3 部署网站 报"Could not load file or assembly ' System.Web.Helpers “ 错的解决方法
  3. jQuery EasyUI API 中文文档 - 面板(Panel)
  4. poj3233之经典矩阵乘法
  5. 简单的php和apache的安装
  6. CSDN博客越来越垃圾了,到处放广告
  7. android 界面布局
  8. c语言-转义序列
  9. Java学习笔记之I/O
  10. 【AngularJS中的自定义服务service VS factory VS provider】---它们的区别,你知道么?
  11. java数据库编程之高级查询
  12. leetcode刷题六<z字形变换>
  13. [IOI2018]高速公路收费——二分查找+bfs
  14. C语言进度条实现。(转)
  15. 第10章-Vue.js 项目实战
  16. Largest Number(leetcode 179)
  17. 目前最快速的多线程Kmeans算法,java实现
  18. iScroll4插件的使用实例
  19. Memory leak patterns in JavaScript
  20. Arduino开发版学习计划--蜂鸣器

热门文章

  1. ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(一)
  2. PAT 甲级 1090 Highest Price in Supply Chain
  3. MySQL与Oracle集群主从复制工具
  4. Linux命令(十) 在文件或目录之间创建链接 ln
  5. [转帖学习]Oracle的 SYS_CONTEXT 函数简介
  6. DataGridView列标题居中,内容居中
  7. Exploring Pyramids UVALive - 3516 (记忆化DP)
  8. Kangax 的 ES7 兼容性表格
  9. 【CF949D】Curfew(贪心)
  10. 40+ 个非常有用的 Oracle 查询语句