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
14 odpowiedzi
+ 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
+ 1
It's infinite while loop
+ 1
But before that you assign greater value to the same variable.
So the decrement means nothing
+ 1
The decrement operator -- doesn't even exist in python
0
But i have put decrement operator there
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
0
Ok now i edited but still getting same error
0
Now i have used different accumulator
0
Oh ok anna
0
Been almost 7 months since i did python
0
Is there any shorthand operator to decrease value by one
0
And i wonder if -- doesn't exist why didn't it give some syntax error
0
Ok thanks
0
You've been most helpfulAnna