Article View: comp.lang.pascal.misc
Article #33Re: Tough FACTORIAL math problem...
From: Dann Corbit
Date: Thu, 15 Feb 1996 18:42
Date: Thu, 15 Feb 1996 18:42
24 lines
1666 bytes
1666 bytes
In article <4fr8be$ass@news.iconn.net>, thecrow@iconn.net says... > >Here is what I am trying to do, I want to find the last NON-ZERO digit of a >given factorial. For instance, > >5! = 120 > >so the last non-zero digit is 2. I want to be able to do this up to 1000. >Problem is, no matter how huge of a data-type you use, there isn't any way for >the computer to handle 1000!, it is however possible to find the last non-zero >digit somehow. One thing I have tried is as I went through mulitplying the >series of numbers in the factorial (5 * 4 * 3 * 2) I would remove all the >trailing ZEROS, I got this to work up to 789, but it wont work with 1000 and i >am not really sure why. If anyone has a clue how I can do this let me know. Actually, long double on INTEL or HFLOAT on the VAX will handle 1754!. If you just want to find the final digit, after each multiplication, remove the trailing digits by dividing by ten. Then take a modulus with ten. The final digit is going to be the result of the product of the two least significant digits. -- The opinions expressed in this message are my own personal views and do not reflect the official views of Microsoft Corporation.
Technical Details
Message-ID:
<4fvuqn$2hk@news.microsoft.com>Path:
arc1-ca.pugleaf.net!news.microsoft.com!newsReferences:
<4fr8be$ass@news.iconn.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.microsoft.com!news From: a-cnadc@microsoft.com (Dann Corbit) Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland Subject: Re: Tough FACTORIAL math problem... Date: 15 Feb 1996 18:42:31 GMT Organization: Microsoft Corporation Message-ID: <4fvuqn$2hk@news.microsoft.com> References: <4fr8be$ass@news.iconn.net> NNTP-Posting-Host: 157.57.171.202 Mime-Version: 1.0 X-Newsreader: WinVN 0.93.14