-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem02.py
51 lines (39 loc) · 1.17 KB
/
problem02.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python2.7
"""
#=============================================================================#
FILE : problem02.py
DESCRIPTION : Project Euler--Problem2 solution/implementation
in Python
REQUIREMENTS : None
BUGS : Must be somewhere hiding :P.
NOTES :
AUTHOR(s) : Spyros Lalos (spyroslal@gmail.com)
CREATED : Nov 06 23:04:12 CEST 2014
This program is free software: you can redistribute it and/or modify
freely
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#=============================================================================#
"""
import sys
def fibo ():
# define start integers
a = 1
b = 2
flist = []
flist.append (1)
flist.append (2)
c = a + b
sum = 2
while True :
c = a + b
if c >= 4000000:
break
if c%2 == 0:
sum += c
flist.append(c)
a = b
b = c
print "{0}:{1}".format ( "Current fibonacci: ", c)
print "Fibonacci list is: {0} and Sum of even numbers is {1}".format(flist, sum)