Large Integer Calculator

Here is a simple calculator that can be used to perform large integer calculations. It's an RPN calculator which operates using a stack. Pressing ENTER pushes the number onto the stack. Pressing an operation manipulates the items on the stack and puts the result back onto the stack. So to compute 5 x 7 you would press 5, hit ENTER, press 7 and then press the times (x) key. The result will appear in the box marked X. X is the top of the stack. Y is the next element on the stack. Additional elements may be present but are not visible.

y↔x swaps the X and Y elements. ← clears the last character entered. n! computes the factorial of n and yx computes y to the xth power. These will generate very large numbers. Try it.

Y
X
0

Handling large integers on a computer is not straightforward. Computers normally keep numbers as binary, typically in a word (32 bits) or double word (64 bits). This only allows for an integer of up to about 4.3 billion or 18.5 quintillion; not very big when you think about it.

If you want larger numbers then you need to go beyond the computer's intrinsic integer size. Suffice it to say when you do that the arithmetic is no longer trivial. Computers have an add and multiply which works fine on small numbers. Not so much on large ones. Big number arithmetic must be done using algorithms, and depending upon the algorithm chosen the (+, -, x, and /) operations may be fast or slow.

To generate very large numbers the calculator provides two functions - Factorial and Power. As you recall, to calculate n factorial (denoted n!) one multiplies n by n-1, etc down to 1.

n! = n x (n-1) x (n-2) x ... x 3 x 2 x 1

Factorials easily generate very large integers.

Just look at how these factorials for small numbers increase:
7! = 5,040
8! = 40,320
9! = 362,880
10! = 3,638,800

As you can see the result gets large very quickly. What do you think 100! is? Try it.

We can also build large numbers quickly by raising a number to a power.

Look at these examples:
77 = 823,543
88 = 16,777,216
99 = 387,420,489
1010 = 1,000,000,000

Note that raising a number to a itself as a power is much larger than the factorial of that number.