Why does this code show time limit exceeded | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does this code show time limit exceeded

This is a simple code to calculate factorial of a given number https://code.sololearn.com/cLe795Mcf54v/?ref=app

17th Mar 2019, 12:36 PM
Divyansh Dabral
Divyansh Dabral - avatar
14 Answers
+ 5
x -= 1 --x doesn't give you an error because it isn't wrong. It just doesn't do anything. It's the negative value of the negative value. --x = x => -(-5) = 5. You could use -------x as well, which will be the same as -x. But you don't do anything with that value, so the whole statement is useless
17th Mar 2019, 12:55 PM
Anna
Anna - avatar
+ 1
It's infinite while loop
17th Mar 2019, 12:39 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
But before that you assign greater value to the same variable. So the decrement means nothing
17th Mar 2019, 12:41 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
The decrement operator -- doesn't even exist in python
17th Mar 2019, 12:45 PM
Anna
Anna - avatar
0
But i have put decrement operator there
17th Mar 2019, 12:40 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Oh damn, sorry i used the same damn variable as accumulator, gosh i don't know how i didn't catch such a stupid typo
17th Mar 2019, 12:43 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Ok now i edited but still getting same error
17th Mar 2019, 12:46 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Now i have used different accumulator
17th Mar 2019, 12:46 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Oh ok anna
17th Mar 2019, 12:47 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Been almost 7 months since i did python
17th Mar 2019, 12:47 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Is there any shorthand operator to decrease value by one
17th Mar 2019, 12:49 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
And i wonder if -- doesn't exist why didn't it give some syntax error
17th Mar 2019, 12:50 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
Ok thanks
17th Mar 2019, 12:58 PM
Divyansh Dabral
Divyansh Dabral - avatar
0
You've been most helpfulAnna
17th Mar 2019, 12:59 PM
Divyansh Dabral
Divyansh Dabral - avatar