Skip to content

Commit f3ae6ab

Browse files
committed
rename var to avoid redefining builtin
1 parent ade54cc commit f3ae6ab

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Diff for: project_euler/problem_01/sol2.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ def solution(n: int = 1000) -> int:
1919
83700
2020
"""
2121

22-
sum = 0
22+
total = 0
2323
terms = (n - 1) // 3
24-
sum += ((terms) * (6 + (terms - 1) * 3)) // 2 # sum of an A.P.
24+
total += ((terms) * (6 + (terms - 1) * 3)) // 2 # total of an A.P.
2525
terms = (n - 1) // 5
26-
sum += ((terms) * (10 + (terms - 1) * 5)) // 2
26+
total += ((terms) * (10 + (terms - 1) * 5)) // 2
2727
terms = (n - 1) // 15
28-
sum -= ((terms) * (30 + (terms - 1) * 15)) // 2
29-
return sum
28+
total -= ((terms) * (30 + (terms - 1) * 15)) // 2
29+
return total
3030

3131

3232
if __name__ == "__main__":

Diff for: project_euler/problem_01/sol3.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,38 @@ def solution(n: int = 1000) -> int:
2222
83700
2323
"""
2424

25-
sum = 0
25+
total = 0
2626
num = 0
2727
while 1:
2828
num += 3
2929
if num >= n:
3030
break
31-
sum += num
31+
total += num
3232
num += 2
3333
if num >= n:
3434
break
35-
sum += num
35+
total += num
3636
num += 1
3737
if num >= n:
3838
break
39-
sum += num
39+
total += num
4040
num += 3
4141
if num >= n:
4242
break
43-
sum += num
43+
total += num
4444
num += 1
4545
if num >= n:
4646
break
47-
sum += num
47+
total += num
4848
num += 2
4949
if num >= n:
5050
break
51-
sum += num
51+
total += num
5252
num += 3
5353
if num >= n:
5454
break
55-
sum += num
56-
return sum
55+
total += num
56+
return total
5757

5858

5959
if __name__ == "__main__":

0 commit comments

Comments
 (0)