|
|
Answers:
int gcd(int a, int b) { if (a==0 && b==0) return -1; if (b==0) return a; return gcd(b,a%b); }
int lcm (int a, int b) { return (int) (a*b)/gcd(a,b); }
Posted by: Nutan
Contact Nutan
#include<stdio.h>
main()
{
int a, fact;
printf("
Enter any number: ");
scanf ("%d", &a);
fact=rec (a);
printf("
Factorial Value = %d", fact);
}
rec (int x)
{
int f;
if (x==1)
return (1);
else
f=x*rec(x-1);
return (f);
}
Posted by: abhijit halder
Contact abhijit halder
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
There should not be any Spelling Mistakes.
There should not be any Gramatical Errors.
Answers must not contain any bad words.
Answers should not be the repeat of same answer, already approved.
Answer should be complete in itself.
   
|