Chinaunix首页 | 论坛 | 博客
  • 博客访问: 120004
  • 博文数量: 24
  • 博客积分: 3030
  • 博客等级: 中校
  • 技术积分: 580
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-11 10:58
文章分类

全部博文(24)

文章存档

2011年(2)

2010年(4)

2009年(10)

2008年(8)

我的朋友
Q2

分类:

2011-06-27 13:35:52

Problem 2

19 October 2001

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

A:
fib 1 = 1
fib 2 = 2
fib n = fib(n-1) + fib(n-2)

sum [x|x<-[fib n | n<-[1..4000000]], even x]
阅读(189) | 评论(0) | 转发(0) |
0

上一篇:Q1

下一篇:没有了

给主人留下些什么吧!~~