WAP to find the product of first N natural numbers in python
Answers
Answered by
12
Hi,
here u go with ur answer..
Program to calculate sum of first n natural numbers in Python
- Output 1: Enter the value of n: 6 Sum of first 6 natural numbers is: 21.
- Output 3: Enter the value of n: -10 Enter a whole positive number!
- Output 4: Enter the value of n: 20 Sum of first 20 natural numbers is: 210.
Mark the answer as BRAINLIEST
Answered by
1
Answer:
Hey! Here is your python code...
def factorial(n):
prod = 1
while n>=1:
prod*=n
n = n-1
return prod
x = int(input("Enter a number: "))
f = factorial(15)
print("Factorial of", x, '=', f)
# Hope this helps!!
Similar questions