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:
Sanders Lin 2018-12-05 21:25:01 +08:00 committed by Libin Yang
parent dab312e0e7
commit 362270c19f
2 changed files with 4 additions and 8 deletions

View File

@ -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)

View File

@ -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)