0

Optimizing and Shortening Code

How can I optimize the given code which calculates the factorial of a number. https://code.sololearn.com/c7m1MD6M4IsP/?ref=app

5th Feb 2020, 4:01 PM
Utkarsh Prajapati
Utkarsh Prajapati - avatar
2 Respostas
+ 5
I'd go like this. n=1 for i in range(2, int(input()+1)): n*=i print(n) Regard the +1: input of 5 should give 120 as a result, but range(5) stops after 4.
5th Feb 2020, 4:17 PM
HonFu
HonFu - avatar