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

The main feature that distinguishes the piano from the harpsichord is the
I need help ASAP please answer quickly
From the 7 male and 7 female sales representatives for an insurance​ company, a team of 3 men and 3 women will be selected to attend a national conference on in
Factor over the complex numbers: 36x2 + 9.
Help me please!!!!!!!!!!!!!
Which of these is a way to reduce the possibility of transmitting HIV? A. A mother with HIV breast-feeding her child B. Being in a relationship in which
What kind of listening would you use during a question-and-answer session in a class? appreciative empathetic reflective critical Please answer I'll mark BRAINL
Customer: "I buy the same items every week and my bill is normally $90.00. Why am I now being charged $108.00 for the exact same items?" Employee: "Unfortunatel
Part of one row of the periodic table is shown. Which element’s atoms have the greatest average number of neutrons? A) tin (sn) B) antimony (sb) C) tellurium (t
A circular garden has a radius of 12 meters. What is the area of the garden? Use 3.14 as an approximation for . A. 452.16 m2 B. 475.32 m2 C. 483.25 m2 D