+ 2
Did anyone here think of calling a function inside itself?
The browser entered an infinite cycle. I had to reset the pc. 😬
6 ответов
+ 6
Examples :
https://code.sololearn.com/c3eg8MvlATAf/?ref=app
https://code.sololearn.com/cOInw4yJq7wi/?ref=app
https://code.sololearn.com/cE7lXk0wwKMN/?ref=app
https://code.sololearn.com/c4phTP2wUQ3u/?ref=app
https://code.sololearn.com/cOfMIY803RdZ/?ref=app
https://code.sololearn.com/c4Q0rFUFxZIP/?ref=app
https://code.sololearn.com/cj7pAcAEmqTm/?ref=app
+ 5
There are many codes which call functions inside itself... But you have to set a limit (return) so that it doesn't repeat infinite times.
Yes... When that happens I also have to reboot my PC.
Something like this is where calling a function inside itself works...
But to stop it from calling infinite times... I have used an if statement when input reaches 0.
https://code.sololearn.com/crFMXA837FiF/?ref=app
+ 3
Idequel Bernabel Álvarez whenever a function calls itself then the phenomenon is known as recursion. But to avoid infinite recursion you have to create a base case(condition where recursion have to stop)
+ 3
This is called recursion.
+ 2
Ok.. Thank!! 💪