Quick actions

cmd+k|ctrl+k

Navigation

Languages

rec2

Snippet info

Language

Python

Visibility

public

Author

moin778866.ma

Created

2022-08-01T20:23:57.755305Z

Updated

2022-08-01T20:23:57.755305Z

# breakdown into smaller problems (will lead to the last operation)
# base condition is required to have finite fun calling
# base condition is represtend by answer we have
# let's make a sum of numbers till n 
# sum(n) = sum(n-1) + n
# sum(2) = sum(1) + 2
# sum(1) = sum(0) + 1
def summer(n):
    if n == 1:
        return n
    
    return summer(n-1)  + n
    
print(summer(3))


# let's make something with recursive
INFO