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

Why is the name "Ship-Trap Island" in the short story "The Most Dangerous Game" ironic?
which of these correctly matches an organelle with its function -chloroplast—movement - nucleus—cell regulation -vacuole—energy production - mitochondrion—phot
A car accelerates from 0 m/s to 30 m/s in 8 seconds. What was its acceleration?
a unit of volume with dimensions 1 unit × 1 unit × 1 unit
What happens in any chemical change?
Which has the highest boiling point ? (a) CH3CH3 (b) CH3OH (c) C2H5OH (d) C3H8
what is the hybridised structure of B2H6?
What happens to nitrogen stored in dead plants and animals?
Think about fire. Can fire be considered a living thing? Why or why not?
How does force change when it is applied to the axle of a wheel and axle?