mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-22 09:12:08 +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
|
j=2
|
||||||
sum=0
|
sum=0
|
||||||
while(j<=n):
|
while(j<=n):
|
||||||
if((j&1)==0): #can also use (j%2==0)
|
if j%2 == 0:
|
||||||
sum+=j
|
sum+=j
|
||||||
temp=i
|
i , j = j, i+j
|
||||||
i=j
|
|
||||||
j=temp+i
|
|
||||||
print(sum)
|
print(sum)
|
||||||
|
|
|
@ -12,9 +12,7 @@ a=0
|
||||||
b=2
|
b=2
|
||||||
count=0
|
count=0
|
||||||
while 4*b+a<n:
|
while 4*b+a<n:
|
||||||
c=4*b+a
|
a, b = b, 4*b+a
|
||||||
a=b
|
count+= a
|
||||||
b=c
|
|
||||||
count=count+a
|
|
||||||
print(count+b)
|
print(count+b)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user