mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-27 10:22:36 +08:00
Modernize Python 2 code to get ready for Python 3
This commit is contained in:
@ -6,6 +6,12 @@ the first 10 terms will be:
|
||||
By considering the terms in the Fibonacci sequence whose values do not exceed n, find the sum of the even-valued terms.
|
||||
e.g. for n=10, we have {2,8}, sum is 10.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
n = int(raw_input().strip())
|
||||
i=1; j=2; sum=0
|
||||
@ -15,4 +21,4 @@ while(j<=n):
|
||||
temp=i
|
||||
i=j
|
||||
j=temp+i
|
||||
print sum
|
||||
print(sum)
|
||||
|
Reference in New Issue
Block a user