Dimitris Kougioumtzis Blog About technology

Sum n numbers

Category Python

Posted on Aug. 23, 2017



Sum n numbers in python


1
2
3
4
5
6
7
8
def sum_first_n_numbers(n):
    '''
    Return the sum of n  numbers
    '''
    if n == 1:
        return n
    else:
        return n + sum_first_n_numbers(n-1)

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere