Sunday, July 19, 2009

Spreadsheet Miscalculation of 30!

Today, I encountered something amusing. I was trying to calculate Factorial 30 (also written as 30!). Don't ask me why I was trying to calculate Factorial. :-).

As a refresher for some of us who may have forgot Factorials, Factorial 30 is product of all positive integers between 1 and 30 inclusive.

30! = 30 x 29 x 28 x 27 x 26 x 25 x 24 x 23 x 22 x 21 x 20 x 19 ... x 1.

With Microsoft Excel, using both PRODUCT function and manual multiplication 30 x 29 x ....

30! = 265,252,859,812,191,000,000,000,000,000,000

Same results on my MacBook with Numbers program, using both PRODUCT function and manual multiplication.

30! = 265,252,859,812,191,000,000,000,000,000,000

I got slightly different result with Google Docs Spreadsheet, using PRODUCT function

30! = 265,252,859,812,191,030,000,000,000,000,000

And, another different result with Google Docs Spreadsheet using manual multiplication

30! = 265,252,859,812,191,100,000,000,000,000,000

But actually,

30! = 265,252,859,812,191,058,636,308,480,000,000

It appears spreadsheets are rounding numbers after 15 or 16 digits.