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

What defines a symbiotic relationship?
What is the length of line segment FJ?
In the introduction to his book, Sedlacek uses the Czech legend of St. Prokop (who harnesses the devil to plough his field) as a metaphor for a commonly-held co
What material did Michelangelo use to sculpt David? a marble b. bronzed marble C. granite d waxed marble
Space satellites in the inner solar system (such as those in orbit around Earth) are often powered by solar panels. Satellites that travel into the outer solar
Periods On the periodic table represent elements
The weather forecasts predicts a 25% chance of snow tomorrow. What is the probability that it does not snow?
i need help with part b
When 1 carbon atom combines with 2 oxygen atoms, the resulting substance is called a(n)
How did the u.s. and USSR compete, and in what ways did this competition escalate overtime?