Ask Question

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

+2
Answers (1)
  1. 23 July, 04:41
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a recursive function using pseudocode or C/C++. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers