Q:

math.factorial python

# Python code to demonstrate math.factorial() 
import math 
  
print ("The factorial of 23 is : ", end="") 
print (math.factorial(23)) 
13
import math
x = 3.86356
math.floor(x)
#Returns: 3
math.ceil(x)
#Returns: 4
7
def fact(n):
  return 1 if (n==0 or n==1) else n*fact(n-1)
fact(3)
0
# import built in math module
import math

# Showing usage of pi function
print(math.pi)
2
# Python code to demonstrate the working of factorial() 
  
# importing "math" for mathematical operations  
import math  
  
x = 5
y = 15
z = 8
  
# returning the factorial 
print ("The factorial of 5 is : ", math.factorial(x)) 
print ("The factorial of 15 is : ", math.factorial(y)) 
print ("The factorial of 8 is : ", math.factorial(z)) 
0
// Python mathematical functions include but are not limited to:
print(10+10) // Returns 20 (Addition)
print(10*10) // Returns 100 (Multiplication)
print(10/10) // Returns 1 (Division)
print(10**10) // Returns 10000000000 (10 to the power of 10, 10^10)
print(10-10) // Returns 0 (Subtraction)
print(10>100) // Returns False (If A is greater than B)
print(10<100) // Returns True (If A is less than B)
print(10==10) // Returns True (If A is equal to B)

import math // Required for the function below
print(math.pi) // Returns the first 15 decimal places of Pi
4
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)
n=int(input("Input a number to compute the factiorial : "))
print(factorial(n))

0

New to Communities?

Join the community