# 10 examples of 'program to find factorial of a number in python' in Python

Every line of 'program to find factorial of a number in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``13def factorial():14    """15    This function reads a number and computes its factorial16    """17    print("Problem: Factorial")1819    number = int(input())20    result = 12122    for n in range(2, number+1):23        result *= n2425    print(result)``
``2def factorial(n):3    fact = 14    for i in range(1,n+1):5        fact *= i6    return fact``
``1def factorial(n):2    res = 13    for i in range(2, n + 1):4        res *= i5    return res``
``42def factorial(n):43    """44    normal recursive two_sum45    :return: int46    """47    if n == 1 or n == 0:  # base case for n = 0, 148        return 149    else:  # recursive case when n &gt; 150        return n * factorial(n - 1)``
``2def factorial(n):3    if(n==1):4        return 15    else:6        return(factorial(n-1)*n)``
``11def factorial(n):12		res = i = 113		while i &lt;= n:14			res *= i15			i += 116		return res``
``9def factorial(n):10  if n is 0:11    return 112  else:13    return n * factorial(n-1)``
``34def inverse_factorial(number, round_up=True):35    '''36    Get the integer that the factorial of would be `number`.37    38    If `number` isn't a factorial of an integer, the result will be rounded. By39    default it'll be rounded up, but you can specify `round_up=False` to have40    it be rounded down.41    42    Examples:43    44        &gt;&gt;&gt; inverse_factorial(100)45        546        &gt;&gt;&gt; inverse_factorial(100, round_up=False)47        448        49    '''50    assert number &gt;= 051    if number == 0:52        return 053    elif number &lt; 1:54        return int(round_up) # Heh.55    elif number == 1:56        return 157    else:58        current_number = 159        for multiplier in itertools.count(2):60            current_number *= multiplier61            if current_number == number:62                return multiplier63            elif current_number &gt; number:64                return multiplier if round_up else (multiplier - 1)``
``42def odd_factorialish(n):43	if n == 0:44		return 145	else:46		return odd_factorialish(n // 5) * factorial_coprime(n) % 100000``
``746def prime_number_factorisation(n):747    if n &lt; 2:748        return [n]749    i = 2750    factors = []751    while i * i &lt;= n:752        if n % i:753            i += 1754        else:755            n //= i756            factors.append(i)757    if n &gt; 1:758        factors.append(n)759    return factors``