Lesson 24 of 34
Recursion: తమను తామే పిలుచుకునే Functions
10 min 35 XP
function తనను తానే పిలుచుకుంటే అది 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.ఇంటర్వ్యూలకు ఇష్టమైనది: 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 తనను తాను ఎప్పటికీ పిలుస్తూనే ఉంటుంది, Python దాన్ని RecursionError తో ఆపుతుంది.