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

how many more sunny days and rainy days are there than cloudy days? sunny days=6 cloudy days= 4 rainy days=7
Jason, Wendy, Kevin, and Michelle each entered a frog in an annual frog-jumping contest. Each of their frogs – Hippy, Hoppy, Bounce, and Pounce ­– placed first,
Solve this inequality: x/13+6 less than or equal to 8
Help in Circumference of a circle A small pizza has a diameter of 21 cm. What is the approximate circumference of the pizza? Use = 3.14.
The worlds fastest humans can reach speeds of about 11 m/s in order to increase his gravitational potential energy by an amount equal to his Kinetic energy at f
4 yards equals how many feet
How do you simplify 20/36
A bricklayer uses a cylinder to store sand. The cylinder is 5 ft tall and has a radius of 0.5 ft. Each batch of mortar contains 0.48 ft3 of sand. How many batch
Heat can only move one way. What way is that?
how do you solve 2/3x+15=17? it is confusing. i have been stuck on this problem for a while...