Lesson 24 of 34
Recursion: സ്വയം call ചെയ്യുന്ന Functions
10 min 35 XP
ഒരു function സ്വയം call ചെയ്യുമ്പോൾ അതാണ് recursion. വലിയ പ്രശ്നത്തെ അതേ തരത്തിലുള്ള ചെറിയ പ്രശ്നമാക്കുന്നു. നിർത്താൻ ഒരു base case നിർബന്ധമാണ്.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.Interview-ന്റെ പ്രിയപ്പെട്ടത്: n! (factorial). 5! = 5 × 4 × 3 × 2 × 1 = 120, അതായത് 5! = 5 × 4!
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.Base case ഇല്ലെങ്കിൽ function എന്നെന്നേക്കും സ്വയം call ചെയ്യും, Python അത് RecursionError ഉപയോഗിച്ച് നിർത്തും.