Skip to content

Commit

Permalink
Solve Sum of Consecutive Odd Numbers II in python
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Nov 20, 2024
1 parent cbc6616 commit bbb0495
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions solutions/beecrowd/1099/1099.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
n = int(input())


for _ in range(n):
x, y = map(int, input().split())
x, y = min(x, y), max(x, y)

x += 1
if x % 2 == 0:
x += 1

s = 0
for odd_number in range(x, y, 2):
s += odd_number
print(s)

0 comments on commit bbb0495

Please sign in to comment.