🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Tough FACTORIAL math problem...

#65
From: PIGEON Steven
Date: Mon, 26 Feb 1996 16:27
47 lines
1530 bytes
Harlan Messinger (gusty@clark.net) wrote:
: void getLastFactorialDigits(int results[], // assume sufficient space
:                                            // was preallocated (n+1 bytes)
: 				int n) {
: 
: 	results[0] = 1;
: 	results[1] = 1;
: 	for (int i = 2; i <= n; ++i) {
: 		results[i] = results[i - 1] * i;
: 		while (results[i] % 10 == 0)
: 			results[i] /= 10;
: 		results[i] = results[i] % 10;
: 	}
: 	return;
: }


Ah a! In PASCAL!!! :-) This is a Pascal group!



 function zerofacto(n:integer):integer;
 var s,j,i:longint;
  begin
   s:=1;
   j:=1;
   i:=0;

   while (j<=n) do
    begin
     s:=s*j;
     while ( (s>10) and (s mod 10=0)) do
      begin
       s:=s div 10;
       inc(i);
      end;
     s:=s mod 10;
     inc(j);
    end;
    zerofacto:=s mod 10;
  end;



---------------------------------------------------------------------------
Steven Pigeon,              http://www.iro.umontreal.ca/people/pigeon
graduate student
Technical Details
Message-ID: <4gsn1d$ia@epervier.CC.UMontreal.CA>
Path: arc1-ca.pugleaf.net!feed.umontreal.ca!epsom!not-for-mail
References: <4fr8be$ass@news.iconn.net> <4g2agv$29r@clarknet.clark.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!feed.umontreal.ca!epsom!not-for-mail
From: pigeons@JSP.UMontreal.CA (PIGEON Steven)
Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland
Subject: Re: Tough FACTORIAL math problem...
Date: 26 Feb 1996 16:27:25 GMT
Organization: Universite de Montreal
Distribution: world
Message-ID: <4gsn1d$ia@epervier.CC.UMontreal.CA>
References: <4fr8be$ass@news.iconn.net> <4g2agv$29r@clarknet.clark.net>
NNTP-Posting-Host: epsom.jsp.umontreal.ca
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]