Reply-to: gcf@npac.syr.edu To: java-for-cse@boss Subject: recursion in a Java Date: Sun, 31 Oct 1999 20:18:48 -0500 From: Geoffrey Fox >From java-for-cse-owner Sun Oct 31 15:55:12 1999 Received: from smtp2.netcarrier.net (smtp.netcarrier.net [209.140.172.6]) by postoffice.npac.syr.edu (8.9.3/8.9.3) with SMTP id PAA18019 for ; Sun, 31 Oct 1999 15:55:12 -0500 (EST) Received: (qmail 146 invoked from network); 31 Oct 1999 20:47:13 -0000 Received: from user64.netcarrier.com (HELO DebHome) (198.136.226.64) by smtp.netcarrier.net with SMTP; 31 Oct 1999 20:47:13 -0000 Message-ID: <000701bf23e2$50bce140$40e288c6@DebHome.calvary-church.com> From: "Troy Barlow" To: Subject: Date: Sun, 31 Oct 1999 15:55:49 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0004_01BF23B8.66D2AA20" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 This is a multi-part message in MIME format. - ------=_NextPart_000_0004_01BF23B8.66D2AA20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a general question about programming with recursion in a Java = Application. How do I print out the product so far for a problem that = finds the factorial of a number. Example (3! =3D 3x2x1). I want it to = print out the 1, the 2, and the 3; not just the 3. This is the code I = have, but I don't know how to make it show each of the values-it just = shows the final value. public int findFactorial(int num) { if(num<=3D1) return 1; else return (num*findFactorial(num-1)); } Thanks. For the help. - ------=_NextPart_000_0004_01BF23B8.66D2AA20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have a general question about = programming with=20 recursion in a Java Application. How do I print out the product so far = for a=20 problem that finds the factorial of a number. Example (3! =3D 3x2x1). I = want it to=20 print out the 1, the 2, and the 3; not just the 3. This is the code I = have, but=20 I don't know how to make it show each of the values-it just shows the = final=20 value.
 
public int findFactorial(int=20 num)
{
   =20 if(num<=3D1)
        return=20 1;
    = else
       =20 return (num*findFactorial(num-1));
}
 
Thanks. For the = help.
- ------=_NextPart_000_0004_01BF23B8.66D2AA20-- ------- End of Forwarded Message