🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.misc
Article #58

Re: Tough FACTORIAL math problem...

#58
From: Carl Laurence Gonsalves
Date: Fri, 16 Feb 1996 15:36
34 lines
1783 bytes
In article <4g00u6$gkk@sun001.spd.dsccc.com>,
Mike McCarty <jmccarty@spd.dsccc.com> wrote:
>)Don't just strip the trailing zeros, remove all digits except the last non-ze
>)digit (which is your output) and then multiply by the next number in your seq
>)This keeps the numbers down to a managable level and gives the correct answer
>)no more significant digit can affect the value of the LSD.
>
>Let's try your technique:
>
>	1! = 1 ~ 1
>	2! = 2x1! ~ 2
>	3! = 3x2! ~ 3x2 = 6
>	4! = 4x3! ~ 4x6 = 24 ~ 4
>	5! = 5x4! ~ 5x4 = 20 ~ 0
>
>You should at least think before engaging the fingers.

Perhaps you should try *reading* before engaging the fingers. You'll notice
he said "remove all digits except the last NON-ZERO digit". So one gets:

	1! = 1 ~ 1
	2! = 2x1! ~ 2
	3! = 3x2! ~ 3x2 = 6
	4! = 4x3! ~ 4x6 = 24 ~ 4
	5! = 5x4! ~ 5x4 = 20 ~ 2
	6! = 6x5! ~ 6x2 = 12 ~ 2

This technique does give the correct result.

-- 
        Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
                   Computer Science, University of Waterloo
               http://www.undergrad.math.uwaterloo.ca/~clgonsal/
                   http://www.csclub.uwaterloo.ca/~clgonsal/
Technical Details
Message-ID: <DMvKp5.2wL@undergrad.math.uwaterloo.ca>
Path: arc1-ca.pugleaf.net!undergrad.math.uwaterloo.ca!clgonsal
References: <4fr8be$ass@news.iconn.net> <31224679.6193@born.com> <4g00u6$gkk@sun001.spd.dsccc.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland
Path: arc1-ca.pugleaf.net!undergrad.math.uwaterloo.ca!clgonsal
From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
Subject: Re: Tough FACTORIAL math problem...
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Message-ID: <DMvKp5.2wL@undergrad.math.uwaterloo.ca>
Date: Fri, 16 Feb 1996 15:36:40 GMT
References: <4fr8be$ass@news.iconn.net> <31224679.6193@born.com> <4g00u6$gkk@sun001.spd.dsccc.com>
Nntp-Posting-Host: cayley.uwaterloo.ca
Organization: University of Waterloo