+ 2

Did anyone here think of calling a function inside itself?

The browser entered an infinite cycle. I had to reset the pc. 😬

22nd Feb 2020, 3:50 AM
Idequel Bernabel Álvarez
Idequel Bernabel Álvarez - avatar
6 ответов
+ 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
22nd Feb 2020, 3:53 AM
Utkarsh Sharma
Utkarsh Sharma - avatar
+ 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)
22nd Feb 2020, 5:14 AM
Arsenic
Arsenic - avatar
+ 3
This is called recursion.
24th Feb 2020, 1:10 AM
Sonic
Sonic - avatar
+ 2
Ok.. Thank!! 💪
22nd Feb 2020, 4:08 AM
Idequel Bernabel Álvarez
Idequel Bernabel Álvarez - avatar