Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change the number in 3rd line to get factorial for the number you want. Ex: num = 30

# Python program to find the factorial of a number provided by the user.
# change the value for a different result
num = 6
# To take input from the user
#num = int(input("Enter a number: "))
factorial = 1
# check if the number is negative, positive or zero
if num < 0:
   print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
   print("The factorial of 0 is 1")
else:
   for i in range(1,num + 1):
       factorial = factorial*i
   print("The factorial of",num,"is",factorial)
Comment

PREVIOUS NEXT
Code Example
Python :: uninstall python3 from source on centos 7 
Python :: (models.W042) Auto-created primary key 
Python :: python set workdir 
Python :: time in regression expression python 
Python :: abs function in python 
Python :: rust vs python 
Python :: scrapy shell 
Python :: test with python 
Python :: ordenar lista python 
Python :: pytest logcli to write to file 
Python :: installing required libraries in conda environment 
Python :: pip --version 
Python :: python replace n with actual new line 
Python :: how to set a single main title above all the subplots with pyplot 
Python :: open url from ipywidgets 
Python :: range of y & x in scatter 
Python :: decode utf8 whit python 
Python :: absolute url 
Python :: gensim show_topics get topic 
Python :: django admin.py 
Python :: numpy set nan to 0 
Python :: how to get pytroch model layer name 
Python :: how to read linux environment variable in python 
Python :: how to redirect user in flask response python 
Python :: python select last item in list 
Python :: how to use def in python 
Python :: matplotlib legend get handles 
Python :: python check if number in string 
Python :: hex to string python 
Python :: group by month and day pandas 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =