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 does “a city upon a hill” mean
Which of the following sentences best describes the Progressive Era? It was a period in which many social reforms occurred. It was a period of unchecked abuses
I need help ASAP thank you!
-2(2-2x) = 4-8(1-x) multi step equation
Little Girl Lost: A Case Study on Defective Cellular Organelles Case study answers
Question 1 with 2 blanksLa semana pasada, Manolo y Aurora (querer) dar una fiesta. (Decidir) invitar a seis amigos y servirles mucha comida. Question 2 with 3 b
Which of the following is true about the stock of capital in the economy?(A) Investment and depreciation generally cause the stock of capital to decrease.(B) In
PLZ HELP I ONLY HAVE 7 MIN LEFT Bells can get a lot of people’s attention. They are used to tell people about major events. One bell is even an American landmar
There were 2.4 cups of water in Barkley's water dish. He drank 1.33 cups. How much water is still in the water dish?
A company has a fiscal year-end of December 31: (1) on October 1, $19,000 was paid for a one-year fire insurance policy; (2) on June 30 the company advanced its