Search Results

Search found 1 results on 1 pages for 'user1816377'.

Page 1/1 | 1 

  • recursive cumulative sums

    - by user1816377
    I need to write a program that compute cumulative sums from a list of numbers with def but ONLY with recursion. I did it, but now I need to write the same program without using the method sum, but no success so far. Any idea? my code: def rec_cumsum(numbers): ''' Input: numbers - a list of numbers, Output: a list of cumulative sums of the numbers''' if len(numbers)==0: return numbers return rec_cumsum(numbers[:-1])+ [sum(numbers)] input: 1 [1,2,3] 2 [2, 2, 2, 3] output: 1 [1,3,6] 2 [2, 4, 6, 9]

    Read the article

1