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

Luisa found great deals on the target dollar spot. She bought 35 items and spent a total of $100 on earbuds ($2 each) and fuzzysocks ($3 each). How many earbuds
mean of four numbers a ,b, c, and d is 8 and mean of seven numbers x , y ,z ,a, b, c and d is 12 . Find the mean of x, y and z.
I need help with this
8th grade math, please help.
Identify ing the statement​
two sides of a scalene triangle measure 15cm and 12cm if the perimeter of the triangle is 40cm, fine the length of the third side​
Hamlet stages a performance about a murder to discern Claudius's guilt. This is part of Hamlet's exposition. rising action. climax. falling action.
36733"lik açının derece,dakika ve saniye olarak eşiti aşağıdakilerden hangisidir? A) 10° 14' 13" B)10° 14' 3"
simplify 2√15+√3√15+√3​
Think of an example from your own life such as school, sports, or an extracurricular activity. Develop an analogy to explain why specialization and communicatio