Day 31 of 100 Days of Python
Practising DSA
Today i practised simple recursion.
1
2
3
4
5
6
def sum_to_n(n):
if n==1:
return 1
return n + sum_to_n(n-1)
result =sum_to_n(5)
print(result)
This post is licensed under CC BY 4.0 by the author.