answersLogoWhite

0

factorial using recursion style in c++ is

unsigned int fact(unsigned int a)

{

if (a<=1)

return 1;

else

{

f*=fact(a-1);

return a;

}

}

when using looping structure factorial is

unsigned int fact (unsigned int n)

{

unsigned int i,f=1;

for(i=1;i<=n;i++)

f*=i ;

return f;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Using the Euclid's algorithm find the multiplicative inverse of 1234 mod4321?

Using the extended Euclidean algorithm, find the multiplicative inverse of a) 1234 mod 4321


By using call by reference find the factorial of a number?

chutia mc,bc bhosdika


How do you find common dinomanater in fractions?

Using the Euclidean algorithm


Implement a program to find out the reverse of an integer using recursive functions?

Note: You may need a larger data type, factorials become very big very quickly and may cause an overflow long factorial(int x) { if(x == 1) return 1; . return((long) factorial(x-1) * x);


Can you write an algorithm to find the greatest of three number using class?

Yes. But why?


Write the Pseudocode to find the factorial of a number?

Pseudo code+factorial


Program to find n th fabonacci number?

#include #include using std::cin;using std::cout;using std::endl;using std::tolower;long factorial(const int& N);int main(){int N = 0; //factorial of Nchar command = 'n';do{cout > N;cout


How you can find a factorial of a number without using multiple operator?

If you really wanted to do this, you could simulate multiplication with repeated addition.


Flowchart to find factorial of a given no?

Kat


Write an algorithm to find the root of quadratic equation?

Write an algorithm to find the root of quadratic equation


How do algorithm to find the factorial of a number?

Factorial (n) = n * Factorial (n-1) for all positive values n given Factorial (1) = Factorial (0) = 1. Pseudo-code: Function: factorial, f Argument: positive number, n IF n&lt;=1 THEN RETURN 1 ELSE RETURN n * f(n-1) END IF


Jntu 2-2 oops through java answers?

write a java program to find factorial using recursive and non recursive