Question & Answer
Write a program that prints out a factorial. N factorial (written N!) is defined as N * (N – 1) * (N – 2) * … * 1 For example, 4! is 4 * 3 * 2 * 1 = 24 Ask the user for the value of N. Use for loops and variables to print out N factorial. (Hint: You solve factorial by multiplying the numbers from 1 all the way up to N together. You need a variable to store the result)
Updated December 14, 2025
Write a program that prints out a factorial. N factorial (written N!) is defined as
N * (N – 1) * (N – 2) * … * 1
For example, 4! is
4 * 3 * 2 * 1 = 24
Ask the user for the value of N. Use for loops and variables to print out N factorial.
(Hint: You solve factorial by multiplying the numbers from 1 all the way up to N together. You need a variable to store the result.)
1 Answer
Verified archive