Explain recursion with an example.



Explain recursion with an example...

Answer / nashiinformaticssolutions

o Recursion is a technique where a function calls itself to solve smaller sub-problems.
8. def factorial(n):
9. if n == 1:
10. return 1
11. else:
12. return n * factorial(n - 1)
13. print(factorial(5)) # Output: 120

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

What are the Advantages of HashMap over Vector?

1 Answers  


if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remaining 2 duplicates in sql server 2008

0 Answers  


How can recruiter justified that the candidate is expert in Algorithm and datastructure for Software product development ?

0 Answers  


please any one pass file aid,xpeditor and endeavor tools

0 Answers  


i want to insert textbox value to sql db. i have only one text box but store four values. ple give any one give sample code in asp.net c#..

1 Answers   Concentrix,


When you?re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?

2 Answers   BirlaSoft,


Need provab technical test questions

0 Answers  


how many languages .net is supporting now?

2 Answers  


How many packages available in java??

7 Answers   CTS,


hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

0 Answers  


What is the difference between procedure -oriented language and object oriented language?

22 Answers   IBM, Infosys, TCS,


how do i add a column dynamically in a table by using java application?

0 Answers  


Categories