# How to do a factorial calculator mathematically

## Indian mental arithmetic

### The mathematical proof

The Indian schoolboy chose one first Reference number Z, namely the number 500. Then he took it first number A (496) and calculated the difference to the reference number Z in his head. The result was 500 - 496 = 4. He deducted that from the second number B (494). The result was 494 - 4 = 490. He took that with the reference number 500 times by first calculating half of 490 (= 245) and then taking it as 1000 times. Intermediate result: 245000.

Second, he took the second number B (494) and also calculates the difference to the reference number 500 for her. The result was 500 - 494 = 6. The two differences to the reference number (for number A it was 4, for number B it is 6) he took and then added the result (4 • 6 = 24) to the intermediate result 245000. So he came to the end result 245024.

Mathematically, what the boy did looks like this:

[B - (Z - A)] • Z + (Z - A) • (Z - B)

You can easily solve it mathematically, it looks like this:

B • Z - Z • Z + A • Z + Z • Z - B • Z - A • Z + A • B

As you can see, there are B • Z and –B • Z, –Z • Z and + Z • Z, A • Z and –A • Z. All of that cancel each other out. All that remains is A • B. The result is A times B, in our example the number A (496) times the number B (494).

So that is proved that the Indian calculation method always leads to the correct result. So it is not a "trick" that only works sometimes, but real math that makes calculating with high numbers in the true sense of the word child's play.