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

1.Mutating table

0 Answers  


how can we get version of database ?

1 Answers  


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  


how do u handle table control inbdc explain the process in steps iwant the answer in urgent please forward this even i know how to explain there

0 Answers   Synopsis,


what are wrapper classes

2 Answers  


Hello Experts, What is the difference between move and move corresponding exactly? please post me asap

0 Answers  


what is log files in qtp what is use

0 Answers   HSBC,


What is Boxing?

3 Answers  


Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming

1 Answers  


if 2 is passed as an argument to the method,void GC.Collect then what would be the result?

0 Answers  


what is the abap/4

1 Answers  


is try block possible without catch block?

3 Answers  


Categories