+ 1

Find out the error

n=input("Enter the number") fact = 1 for i in range(1,int(n)): fact = fact * i print(fact) Output: Enter the number5 24 Expected output: 120

8th Oct 2018, 3:56 PM
Pandiselvi
1 Answer
+ 4
range(1, n) doesn't include n. It's from 1 to n-1. So you need to change it to range(1, n+1).
8th Oct 2018, 4:17 PM
Anna
Anna - avatar