mirror of
https://github.com/onyx-and-iris/grokking-algorithms.git
synced 2024-11-15 17:30:52 +00:00
14 lines
264 B
Python
14 lines
264 B
Python
class Number:
|
|
def __init__(self, value):
|
|
self.value = value
|
|
|
|
|
|
def summation(nums):
|
|
if len(nums) == 1:
|
|
return nums[0].value
|
|
return nums[0].value + summation(nums[1:])
|
|
|
|
|
|
nums = [Number(i) for i in range(0, 100, 3)]
|
|
print(summation(nums))
|