+ 1
Factorial by fun,...I want to know how loop is working ,little confused,help me out
Def factorial Fact=1 For i in range(1,n+1) Fact*=i Return Fact
2 Answers
+ 4
NAVEEN VYAS
factorial(5)
range(1, n + 1) means range(1, 6) = [1, 2, 3, 4, 5]
So fact *= i means fact = fact * i
So fact = 1 * 1 * 2 * 3 * 4 * 5 = 120
+ 1
With a loop will be the statements, which are within it, repeated and so many times, how the range big is.