mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-20 08:12:02 +00:00
Project Euler problem 2 pyhtonic solution (#629)
* Project Euler problem 2 pyhtonic solution * Project Euler problem 2 made small changes
This commit is contained in:
parent
dab312e0e7
commit
362270c19f
|
@ -18,9 +18,7 @@ i=1
|
|||
j=2
|
||||
sum=0
|
||||
while(j<=n):
|
||||
if((j&1)==0): #can also use (j%2==0)
|
||||
if j%2 == 0:
|
||||
sum+=j
|
||||
temp=i
|
||||
i=j
|
||||
j=temp+i
|
||||
i , j = j, i+j
|
||||
print(sum)
|
||||
|
|
|
@ -12,9 +12,7 @@ a=0
|
|||
b=2
|
||||
count=0
|
||||
while 4*b+a<n:
|
||||
c=4*b+a
|
||||
a=b
|
||||
b=c
|
||||
count=count+a
|
||||
a, b = b, 4*b+a
|
||||
count+= a
|
||||
print(count+b)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user