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

Need help please answer
Can someone please help??? Your family bought a new board game for Family Game Night, but when you open the box the instructions are missing. What is the best s
There is a correlation between the mean temperature and ice cream sales. Which of the following statements are true? Check all that apply.-Based upon the study,
16. Jill wants to build a planter box that is in the shape of a right triangle. The hypotenuse will be 8 feet long. If the two sides of the triangle are to be t
The quotient of triple a number less four and five equals two. What is the number?
What are the consecutive numbers that follow the number 686
4/9 7/21 change to percent
Question 3 of 10 Which visual element of the National Geographic video most clearly sends a message that the flu is worrisome? A. The images of a miserable litt
how large was the largest christmas cracker ever made?
How do the 2s in 12.5 and 0.912 compare? A The value of the 2 in 12.5 is 11,000 the value of the 2 in 0.912. B The value of the 2 in 12.5 is 1100 the value of