Question: Exercise 4. (Factorial) Write a program factorial.py that takes n (int) as command-line argument, and writes to standard output the value of nl, which is

Exercise 4. (Factorial) Write a program factorial.py that takes n (int) as command-line argument, and writes to standard output the value of nl, which is defined as n! = 1 x 2 x ...(n-1) xn. Note that 0!= 1.

>_/workspace/project2 $ python3 factorial.py 0 $ python3 factorial.py 5 120 factorial.py

import stdio

import sys

# Get n (int) from command line

n= . . .

# Set result to 1.

. . .

for i in range (... , ...)

# For each value of i from [2, n]. set result to its current value times i.

#Write result to standard output.

. . .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!