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

a chip board has 10 black chips and 13 red chips what is the value of the chip board
I need help with my biology test. there are 6 questions. 1.True or False, There are only two broad categories called kingdoms. 2.True or False, Before classifi
Lab: Charles's Law Assignment: Lab Report Does anyone have this LAB REPORT FULLY completed on edge?​
please help me as soon as you see this 10 points or five points going out for you 3×1+ 2×(1/10) + 6x (1/100) +5×(1/1000)?​
which statement is most accurate about individuals known as scalawags?
write an equation in slope-intercept for $0.50 per ride, $1.03 per mile and a $1.38 flat fee
What is the expected value of X? X 3 4 5 7 9 P 0.2 0.1 0.25 0.05 0.4 6.2 6.05 5.95 5.6
Question 12 The graph represents the amounts Madison and Morgan earn each hour tutoring. After how many hours will Madison and Morgan earn the same amount? Amou
What is the real reason that Josh doesn't want to stop at Pollard's Chicken and BBQ after the game
The quartering act, why was it so hard for the colonists