diff --git a/chapter4/summation.py b/chapter4/summation.py new file mode 100644 index 0000000..a540f74 --- /dev/null +++ b/chapter4/summation.py @@ -0,0 +1,13 @@ +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))