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

please help i will give brainliest:(
Help please. What would be 1 factor and descriptor of climate??
Will apples be sweeter when the tree gets enough water?
Which of the following statements is true about the food chain below? Grass ⇒ grasshopper ⇒ bird ⇒ hawk The amount of energy transferred from the grass to the g
A car travels at an average speed of 55 miles per hour. How many miles dors the car travel in 2.5 hours?
Where do you think it is most difficult to practice social distancing?
Write a Python class, Flower, that has three instance variables of type str, int, and float, that respectively represent the name of the flower, its number of p
A 9-ounce box of strawberry gelatin costs $0.90, and a 6-ounce box costs $0.42. What is the difference in cost (per ounce) between the larger and the smaller bo
is 6 and 2/3 less then 6.3?
If the sum of two numbers is 15 and their quotient is 4, what are they?