Skip to main content

Welcome to Coding 4 Programming

Addition of Two Binary Numbers | Function | Python

Sum of Natural N number | Recursion Function | Python

To find Sum of First N Number in Python Using Recursion Function.


  1. def sumf(n):
  2.     if(n>0):
  3.         return n+sumf(n-1)
  4.     else:
  5.         return n
  6. n=int(input("Enter Number="))
  7. sm=sumf(n)
  8. print("Sum of",n,"Natural Numbers is",sm)

Snapshot:

Snapshot of the Above Program

Note:

  • If you have any problem related to this program. Please do comment your Problem or Mail us.
  • For illustrating the any concept you can comment by line number.
  • Thank you! For more programs do regular visit to Coding 4 Programming.

Comments

Popular Posts