+ 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

13th Feb 2022, 5:46 PM
NAVEEN VYAS
2 odpowiedzi
+ 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
13th Feb 2022, 5:53 PM
A͢J
A͢J - avatar
+ 1
With a loop will be the statements, which are within it, repeated and so many times, how the range big is.
13th Feb 2022, 5:51 PM
JaScript
JaScript - avatar