def rec_cumsum(numbers):
''' Input: numbers - a list of numbers,
Output: a list of cumulative sums of the numbers'''
if len(numbers) <= 1:
return numbers
new_list=numbers[:-1]
last=numbers[-1]
rec = rec_cumsum(new_list)
rec.append(rec[-1]+last)
return rec
tests = [[],
[1],
[1,2],
[1,2,3],
[1,2,1,3]]
for t in tests:
print(rec_cumsum(t))
ZGVmIHJlY19jdW1zdW0obnVtYmVycyk6CiAgICAnJycgSW5wdXQ6IG51bWJlcnMgLSBhIGxpc3Qgb2YgbnVtYmVycywKICAgICAgICAgICAgT3V0cHV0OiBhIGxpc3Qgb2YgY3VtdWxhdGl2ZSBzdW1zIG9mIHRoZSBudW1iZXJzJycnCiAgICBpZiBsZW4obnVtYmVycykgPD0gMToKICAgICAgICAgcmV0dXJuIG51bWJlcnMKICAgIG5ld19saXN0PW51bWJlcnNbOi0xXQogICAgbGFzdD1udW1iZXJzWy0xXQogICAgcmVjID0gcmVjX2N1bXN1bShuZXdfbGlzdCkKICAgIHJlYy5hcHBlbmQocmVjWy0xXStsYXN0KQogICAgcmV0dXJuIHJlYwoKdGVzdHMgPSBbW10sCiAgICAgICAgIFsxXSwKICAgICAgICAgWzEsMl0sCiAgICAgICAgIFsxLDIsM10sCiAgICAgICAgIFsxLDIsMSwzXV0KZm9yIHQgaW4gdGVzdHM6CiAgICBwcmludChyZWNfY3Vtc3VtKHQpKQoKCg==