Message-ID: <002301be5318$9d1b86e0$461b2bc8@luis> From: "Luis Pistoia" To: Subject: recursive factorial Date: Mon, 8 Feb 1999 01:07:12 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0020_01BE52FF.5C0AC3A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_0020_01BE52FF.5C0AC3A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Could anyone give me a little help? I'm trying to use recursive programming for getting a factorial of a = number. The source I've made is: =20 #include #include long int rcs_factorial(long int); =20 main(){ int num; printf("Factorial of: "); scanf("%d",&num); printf(" %ld",rcs_factorial(num)); } =20 long int rcs_factorial(long int passed){ if(passed <=3D1 ){ printf("%d =3D ",passed); return 1; } else{ printf("%d * ",passed); return passed * rcs_factorial(--passed); } } But it doesn't work. It does the rigth number of calls to rcs_factorial = but fails at doing the first multiplication. =20 Thanks. Luis. =20 ------=_NextPart_000_0020_01BE52FF.5C0AC3A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Could anyone give me a little help?
I'm trying to use recursive programming for getting = a=20 factorial of a number. The source I've made is:
 
#include <stdio.h>
#include = <stdlib.h>
long=20 int rcs_factorial(long int);
 
main(){
int num;
printf("Factorial of:=20 ");
scanf("%d",&num);
printf("=20 %ld",rcs_factorial(num));
}
 
long int rcs_factorial(long int passed){
  = if(passed=20 <=3D1 ){
    printf("%d =3D=20 ",passed);
    return 1;
  }
 =20 else{
    printf("%d *=20 ",passed);
    return passed *=20 rcs_factorial(--passed);
  }
}
But it doesn't work. It does the rigth number of = calls to=20 rcs_factorial but fails at doing the first multiplication.
 
Thanks.
Luis.
 
------=_NextPart_000_0020_01BE52FF.5C0AC3A0--