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)

Problem 2的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [LeetCode] Water and Jug Problem 水罐问题

    You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  10. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

随机推荐

  1. 基于java注解实现自己的orm框架

    ORM即Object Relation Mapping,Object就是对象,Relation就是关系数据库,Mapping映射,就是说Java中的对象和关系数据库中的表存在一种对应关系. 现在常见的 ...

  2. Java异常的捕获与处理

    Java提供了try(尝试).catch(捕捉).finally(最终)这三个关键字来处理异常.在处理各种异常时,需要用到对应的异常类,指的是由程序抛出的对象所属的类. 一.异常处理的使用 由于fin ...

  3. POJ2689 Prime Distance 质数筛选

    题目大意 求区间[L, R]中距离最大和最小的两对相邻质数.R<2^31, R-L<1e6. 总体思路 本题数据很大.求sqrt(R)的所有质数,用这些质数乘以j, j+1, j+2... ...

  4. Linux - Nginx配置反向代理。

    Nginx配置反向代理. 准备两台服务器 http://192.168.70.66 http://192.168.70.62 设置正则匹配(192.168.70.66) vim /usr/local/ ...

  5. [BZOJ 2100] Apple Delivery

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2100 [算法] Answer = min{ dist(PB,PA1) + dist( ...

  6. netcore发布到centos 验证码Zkweb.system.drawing不显示及乱码的问题

    netcore发布到centos 使用的是Zkweb.system.drawing生成验证码,发布后可能会出现不显示及乱码的情况 1.验证码图片不显示(通过日志会发现生成图片时代码已经异常) Zkwe ...

  7. SQL server存储过程学习

    由于之前使用 Linq to Sql来操作数据库,对于数据库的存储过程.函数等比较薄弱.乘着自己闲着的时候,就百度自学了一点存储过程,以防以后要用. 基础通俗易懂的存储过程通过 存储过程学习 ,然后自 ...

  8. Super超级ERP系统---(4)采购管理--采购单创建

    Erp系统中采购是系统必不可少的一部分,也就是ERP种的进货模块,超级ERP系统中的采购模块选选择采购供应商,然后选择进货商品的数量和采购价格,创建采购进货单 1.创建采购单 2.审核采购单 采购单创 ...

  9. 异步lambda表达式

  10. hiho一下 第173周

    题目1 : A Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playing a game. Ther ...