# UVa 10323

## Summary

The concept behind the problem is quite simple - given ${\displaystyle n}$, if ${\displaystyle n!}$ is greater than 6227020800, then print "Overflow!", if ${\displaystyle n!}$ is less than 10000, print "Underflow!", and otherwise print ${\displaystyle n!}$. Unforunately, there's a little trick..

## Explanation

Though negative factorial are normally undefined this problem stretches the limit of well-known definitions.

For this problem, we have ${\displaystyle F(n)=n*F(n-1)}$, and ${\displaystyle F(0)=1}$. With some manipulations, for negative factorials, we can get: ${\displaystyle F(0)=0*F(-1)}$, or ${\displaystyle F(-1)={\frac {F(0)}{0}}=\infty }$. Continuing on this logic: ${\displaystyle F(-1)=-1*F(-2)}$, or ${\displaystyle F(-2)=-F(-1)}$. Similarly, ${\displaystyle {\frac {F(-1)}{-1}}=F(-3)=-F(-2)}$.

To ignore all the non-sense, if the input is between 8 to 13, print ${\displaystyle n!}$. It's always overflow if ${\displaystyle n\geq 14}$, and always underflow from 0 to 7. For negative numbers, negative odd numbers are overflows, and negative even numbers are underflows.

## Gotchas

• Read above. The entire problem is a gotcha.

## Input

-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15


## Output

Overflow!
Underflow!
Overflow!
Underflow!
Overflow!
Underflow!
Underflow!
Underflow!
Underflow!
Underflow!
Underflow!
Underflow!
Underflow!
40320
362880
3628800
39916800
479001600
6227020800
Overflow!
Overflow!