Nonrecursive Factorial
Write a nonrecursive version of the Factorial procedure that uses a loop. (A WdeoNote for this exercise is posted on the Web site.) Write a short program that interactively tests your Factorial procedure. Let the user enter the value of n. If overflow occurs in your loop when calculating each fac-torial value, your program should display an error message. If no overflow occurs, display the calculated factorial. Following is a sample of the interaction between the user and the program:
Enter the value of n to calculate the factorial (-1 to quit): 0 The factorial is: 1
Enter the value of n to calculate the factorial (-1 to quit): 1 The factorial is: 1
Enter the value of n to calculate the factorial (-1 to quit): 5 The factorial is: 120
Enter the value of n to calculate the factorial (-1 to quit): 12 The factorial is: 479001600
Enter the value of n to calculate the factorial (-1 to quit): 13 Error: Calculated value cannot fit into 32 bits
Enter tlhe value of n to calculate the factorial (-1 to quit): -1