Automatic commit performed through alias...

This commit is contained in:
Shaun Setlock
2020-08-02 07:38:10 -04:00
parent 675a507520
commit b7bfa36d06
11 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python
# 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.
#
import decorators
@decorators.function_timer
def main():
count = 0
limit = 4000000
n1 = 1
n2 = 1
sumval = 0
while count <= limit:
n3 = n1 + n2
if n3%2 == 0:
sumval += n3
n1 = n2
n2 = n3
count = n3
print("The sum is {}".format(sumval))
main()