dataflair python 1

dataflair python

>>> factorial(5)

Here is what the above code is Doing:
1. The function is called with the argument 5.
2. The function creates a variable called result and assigns it the value 1.
3. The function creates a variable called counter and assigns it the value 1.
4. The function enters a while loop.
5. The function multiplies result by counter and assigns it to result.
6. The function increments counter by 1.
7. The function repeats steps 5 and 6 until counter is greater than 5.
8. The function returns the value of result.

Similar Posts