Showing posts with the label python factorial

Python: How to find factorial Using math

I have explained how to find factorial for a given number in Python using my own script fact.fy. A module is created as a script file, which contains function definitions that can be called in two ways: From the interpreter  From another script file or from another function How to import a Script from Linux to Python Session. I have written a script  fact.fy # This program illustrates the designing/creation of a module def factorial (n): "This module computes factorial" f=1; for i in range (1, n+1): f=f*i; print(f) return   In interpreter... >>>  import fact        ==> Import from Linux >>> fact.factorial(5) 120 What is script reloading? The Python interpreter imports a module only once in a session.  If some modifications are performed in the script, then it must be reloaded (imported) again in the interpreter for future use. A script is a reusable component and you can add n n