bubbleslol1266 bubbleslol1266
  • 20-09-2017
  • Computers and Technology
contestada

Python write a script that takes a number n as input from the user and calculates the factorial n! (that is n*n-1*n-2*n-3*…*1)

Respuesta :

rsmith6559
rsmith6559 rsmith6559
  • 21-09-2017
#!/usr/bin/python

import sys

def factorial( n ):
    if( n > 1 ):
        return( n * factorial( n - 1 ) )
    else:
         return( 1 )

if( __name__ == "__main__" ):
    print factorial( int( sys.argv[ 1 ] ) )

Answer Link

Otras preguntas

Read the passage. Researchers in Sweden decided to conduct testing on an individual buried in a famous Viking grave. The grave is known as Bj 581. This grave co
The area of the triangle is 42 square inches. Determine the length of the height, by applying the formula of area of triangle.
How could a strategy plan be used by a local restaurant chain
What is the value of this number in decimal form? Three hundred sixty-seven thousandths.
The base of a triangle is 6 meters longer than the height of the triangle. If the area of the triangle is 108 square meters, what are the base and height of the
Reasons why South African post office taking private courier companies to court​
Ese dia los niños ————disfraces y piden dulces
Hot water is added to three times its water at 10 degree Celsius and the resulting temperature at 20 degree Celsius. what is the initial temperature ​
how to investigate the action of water on calcium metal ​
describe the crystalline alostropy form of carbon​