Skip to content

Commit 362270c

Browse files
SandersLinyanglbme
authored andcommitted
Project Euler problem 2 pyhtonic solution (TheAlgorithms#629)
* Project Euler problem 2 pyhtonic solution * Project Euler problem 2 made small changes
1 parent dab312e commit 362270c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

project_euler/problem_02/sol1.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
j=2
1919
sum=0
2020
while(j<=n):
21-
if((j&1)==0): #can also use (j%2==0)
21+
if j%2 == 0:
2222
sum+=j
23-
temp=i
24-
i=j
25-
j=temp+i
23+
i , j = j, i+j
2624
print(sum)

project_euler/problem_02/sol3.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
b=2
1313
count=0
1414
while 4*b+a<n:
15-
c=4*b+a
16-
a=b
17-
b=c
18-
count=count+a
15+
a, b = b, 4*b+a
16+
count+= a
1917
print(count+b)
2018

0 commit comments

Comments
 (0)