Sum Between Bounds
Sometimes you need to quickly add all numbers between two boundaries, even if the boundaries arrive in the opposite order. Write get_sum, which takes two integers a and b and returns the sum of every integer from the smaller one to the larger one, inclusive. If the two numbers are equal, just return that number.
Примеры
Ввод
1, 0Вывод
1Ввод
1, 2Вывод
3Ввод
0, 1Вывод
1Нужно реализовать
def get_sum(a: int, b: int) -> int:
Теги
math
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
1, 0Expected
12
Input
1, 2Expected
33
Input
0, 1Expected
14
Input
1, 1Expected
15
Input
-1, 0Expected
-16
Input
-1, 2Expected
2Focus radio
Paused · SomaFM · Fluid