cruzheidy7486 cruzheidy7486
  • 07-11-2017
  • Computers and Technology
contestada

Write code to complete print_factorial()'s recursive case. sample output if user_val is 5: 5! = 5 * 4 * 3 * 2 * 1 = 120

Respuesta :

rsmith6559
rsmith6559 rsmith6559
  • 07-11-2017
```
#!/usr/local/bin/python3


import sys

def print_factorial( user_val ):
    if( user_val < 1 ):
        return( 1 )
    else:
        return( print_factorial( user_val - 1 ) * user_val )


if( __name__ == "__main__" ):
    if( len( sys.argv ) == 2 ):
        print( print_factorial( int ( sys.argv[ 1 ] ) ) )
    else:
        sys.stderr.write( "usage: %s <integer>\n" % sys.argv[ 0 ] )

    exit( 0 )
```

Answer Link

Otras preguntas

find the missing side length
Explain why these two are not the same: -|x| and |-x|
was the mexican american war justified?
Which set of transformations was performed on PQSR to form P'Q'S'R'? A dilation factor of 2 A dilation factor of 1 over 3 A dilation factor of 1 over 2 A d
I need some help with my lesson pleaseee
Oque leva os colaboradores a dedicar se ao trabalho/ a vestirem a camiseta da empresa e a lutarem por ela?
The diagram shows corresponding lengths in two similar figures. Find the area of the smaller figure. A. 16 cm^2 B. 18 cm^2 C. 20 cm^2 D. 36 cm^2
The ratio of Zaidi's savings to Khairi's savings is 7:2. The two of them save $3600. How much is Khairi's savings?
Help with question???
Iobium-91 has a half-life of 680 years. After 2,040 years, how much niobium-91 will remain from a 300.0-g sample?