mirror of
https://github.com/onyx-and-iris/grokking-algorithms.git
synced 2024-11-16 01:40:53 +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))
|