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

Name two ways your body uses carbohydrates
What is the square root of 49
what is the source for the ultraviolet radiation in earths atmosphere
I need help with #12
Among what people did the worship of one god first emerge and become the foundation of a major religion? a. Israelites b. Egyptians c. Persians d. Sumerians
What invention had the greatest effect on the spread of information
24.2 rounded to the nearest tenth
A rock is rolling down a hill. At position 1, its velocity is 2.0 m/s. Twelve seconds later, as it passes position 2, its velocity is 44.0 m/s. What is the acce
Which of the following equations describe the line shown below? (-2, 3) (1, 9)
What are 5 facts that are in the book escape the story of the great Houdini by Sid fleischman And what is the book about? Also what are three tricky words in th