In this programming assignment, you will use your newfound looping knowledge to compute a factorial that can fit within an unsigned 16 bit integer.
You should use nested loops to try different factorials until you get to one that does not fit, then exit the loop and print a message defining which number became too large.
As you should recall, a factorial is computed like the following:
3! = 3 * 2 * 1
The pseudo code for one way to do this program is shown below. You can use a different method as long as you use nested loops in a way similar to that shown.
num = 10
overflow = false
while (1) {
int16 = 1
for (i = num; i > 0; i--) {
int16 = int16 * i
if (overflow detected) {
overflow = true
break // Break out of inner loop
}
}
if (overflow) {
print "Factorial overflowed 16 bits when number reached ", num
break // Break out of outer loop
}
num = num + 1
}