skybabe9775 skybabe9775
  • 14-09-2019
  • Computers and Technology
contestada

Write a recursive function using pseudocode or C/C++.

Respuesta :

ExieFansler ExieFansler
  • 19-09-2019

Answer:

long fact(int n)

{

   if(n<=1)//base case

   return 1;  

   long p=fact(n-1);//recursive call.

   return n*p;//returning the factorial.

}

Explanation:

Above written function is written in C++ language.It is a recursive function to find the factorial of the function.

If we enter a number  equal to  or  less than  1  then the function returns 1. Then the recursive call  is made  and it is stored  in the long  variable  p and  the result is returned as n*p.

Answer Link

Otras preguntas

Given that ABDC : EFGH, what is m G? 27° 90° 117° 120°
Please help me and explain. Find the area of the figure thanks
HELP MAX POINTS COME FAST Based on what you have learned, choose each response below that correctly describes America’s economic situation at the time of
If the square root of 1 over 2 x - 10 added by 3, which inequality can be used to find the domain of f(x)?
Then, in the small intestine, trypsin, chymotrypsin and ____________ continue the breakdown of proteins.
geometry help!! #48 plz show work
What is the slope of a loading ramp that rises 3 inches for every horizontal change of 12 in?
Economic globalization refers to the economic_____ of nations resulting from mutual____
The federal agency that monitors compliance with title vii is the
Which of the following is NOT part of buddhist beliefs? A)Three Jewels B)Eightfold Path C)Four Noble Truths D)Five Steps