+ 12
Why are we throwing "Time limit exceeded" to number 3 or higher, and on 2 and lower ones?
3 Réponses
+ 5
It is because your variable "x" will never be equal to 3 and you will never get out of recursion.
So this code call factorial function so many times without returning value and all these calls are pushed in the execution stack. After that python stops the program after limit exceeded.
+ 4
Yes, Vladi Petrov is right. Because x will never equal 3, your program will continuously loop, decrementing x by 3 each time, until x = 3, which will never happen. it is an infinite loop
+ 1
like the others said, it's an infinite loop; you have to add a break in whatever direction its going to stop it from executing