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

Can somebody help me with #8?
what is the difference between "x times x"  and "x plus x"?
What Eco region does the Texas Ocelot live in?
Square root of 4+2 root 3
Exposure to UV light stimulates the skin to produce which vitamin? a. A b. B c. C d. D
Can somebody help me with #8?
how to find the diagonals of a parallelogram?
Two equal circles are cut out of a rectangle of card of dimensions 16 by 8. The circles have the maximum diameter possible. What is the approximate area of the
Cos A = square root 21 divided by 5 and sin A = 2/5. What is the exact value of cos 2A?
coal and wood are found in nature.they are both examples of