Let n be a nonnegative integer. The factorial of n, written n!, is defined by 0!=1, n!
Fantastic news! We've Found the answer you've been seeking!
Question:
Let n be a nonnegative integer. The factorial of n, written n!, is defined by 0!=1, n! =1*2*3*...*n if n >= 1. For example, 4! = 1*2*3*4 = 24. Write a program that prompts the user to enter a nonnegative integer and outputs the factorial of the number.
Output format:
4! = 24
0! = 1
Notes: - You must check if the entered integer is non-negative. If it is negative, keep asking the user to input a non-negative integer. You can use infinite
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date: