From bbb04956498bf5162831a3a549726a96437edcb0 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Wed, 20 Nov 2024 10:34:53 -0300 Subject: [PATCH] Solve Sum of Consecutive Odd Numbers II in python --- solutions/beecrowd/1099/1099.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 solutions/beecrowd/1099/1099.py diff --git a/solutions/beecrowd/1099/1099.py b/solutions/beecrowd/1099/1099.py new file mode 100644 index 00000000..95cd06a6 --- /dev/null +++ b/solutions/beecrowd/1099/1099.py @@ -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)