Find extra long factorials in python

Carvia Tech | September 03, 2019 | 1 min read | 159 views | Python Coding Problems

The factorial of the integer n, written n!, is defined as:

\$n! = n*(n-1)*(n-2)*..*3*2*1\$

Calculate and print the factorial of a given integer.

Input Format

Input consists of a single integer n.

Output Format

Print the factorial of n.

Sample Input
Sample Output


\$25! = 25*24*23*22*...*3*2*1\$



This answer passes all the tests

We are going to keep logic in main function only such that we are able to build array as we will be getting data from input. You shall create a file and paste the below code in it.

1st line: arr = int(input()) This takes input from command line. Please note that input type is going to be in string format and we have to use int() to convert from string to int

2nd line: a=1 This is to intialize the number.

Finding extra long factorial of a number: python
if __name__ == '__main__':
    arr = int(input())
    a = 1
    for i in range(1,arr+1):
        a = a*i

Top articles in this category:
  1. Python coding challenges for interviews
  2. Python Flask Interview Questions
  3. Top 100 interview questions on Data Science & Machine Learning
  4. Google Data Scientist interview questions with answers
  5. Sequence of Differences in Python
  6. python problem 1: find the runner-up score
  7. Python send GMAIL with attachment

Find more on this topic:
Machine Learning image
Machine Learning

Data science, machine learning, python, R, big data, spark, the Jupyter notebook, and much more

Last updated 1 week ago

Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info