Problem 2

# Problem_2.py
"""
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.
四百万以下的偶数斐波那契数列之和
"""
def fibonacci(x=1, y=1, end=10000):
if x >= end:
return []
else:
return [x] + fibonacci(y, x+y, end) fib = fibonacci(end=4000000)
print(fib)
num = sum([i for i in fib if i%2==0])
print(num)

最新文章

  1. Swift - 语言指南,来自github学习
  2. poj 1008:Maya Calendar(模拟题,玛雅日历转换)
  3. 查看Sql Server所有表占用的空间大小
  4. Java基础之写文件——使用带缓冲的Writer写文件(WriterOutputToFile)
  5. 项目解析- JspLibrary - part2
  6. DJANGO变动库的一次真实手动经历
  7. Ineligible Devices 不被识别的设备
  8. jqueryMobile中select样式自定义
  9. OpenCms创建站点过程图解——献给OpenCms的刚開始学习的人们
  10. input 和raw_input
  11. BZOJ2720: [Violet 5]列队春游
  12. grub2详解(翻译和整理官方手册)
  13. CSS的box-sizing属性
  14. VS2008下QT开发环境搭建(转)
  15. java返回数据工具类
  16. C# 计算地图上某个坐标点的是否在多边形内
  17. linux 安装nvm,通过nvm安装node
  18. 数据库SQLserver(课本)
  19. ROC,AUC,Precision,Recall,F1的介绍与计算
  20. 用例设计之API用例覆盖准则

热门文章

  1. oc4--方法
  2. 深入解析Dropout——基本思想:以概率P舍弃部分神经元,其它神经元以概率q=1-p被保留,舍去的神经元的输出都被设置为零
  3. CodeForces--621A--Wet Shark and Odd and Even(数学水题)
  4. 软件开发 —— 重构(refactor)
  5. Could not open ServletContext resource [/WEB-INF/Dispatcher-servlet.xml]
  6. 百度jquery公共引用地址
  7. NOIP2013 D2T1 积木大赛
  8. C# How to convert MessageBodyStream to MemoryStream?
  9. 豆瓣项目(用react+webpack)
  10. 如何在Hexo中实现自适应响应式相册功能