answersLogoWhite

0


Best Answer

Let's take the example of finding the factorial of a number (of a positive integer). The factorial of N is N * (N-1) * (N-2) * (N-3) ... * 3 * 2 *1 It is the product of all integers between that number (including that number) and 1. For example, factorial 2 = 2*1 = 2 factorial 3 = 3*2*1 = 6 factorial 4 = 4*3*2*1= 24 Now you define a recursive function Fac (N) as Fac (N) = Fac (N-1) * N, with Fac(1) predefined as 1. Thus, Fac(N-1) = Fac(N-2) * (N-1) and Fac(N-2) = Fac(N-3) * (N-2) and thus recursion takes over until such time fac(1) needs to be evaluated. We know the value of Fac(1) which is set as 1. Thus we can evaluate Factorial(N) using recursion.

User Avatar

Wiki User

18y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an example of using recursive functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic
Related questions

The efficiency of using recursive function rather than using ordinary function?

For some algorithms recursive functions are faster, and there are some problems that can only be solved through recursive means as iterative approaches are computationally infeasible.


Write a c program to find GCD of two given integers by using both recursive n non recursive functions?

i love u darling


What does recursive mean?

Recursive refers to using a rule or procedure that can be applied repeatedly.


Does javascript support recursive functions?

Yes, but a recursive function running for a long time would eventually cause your program to crash.


What has the author J C E Dekker written?

J. C. E. Dekker has written: 'Recursive equivalence types' -- subject(s): Recursive functions


Advantages of using C function?

* Debugging is easier * It is easier to understand the logic involved in the program * Testing is easier * Recursive call is possible * Irrelevant details in the user point of view are hidden in functions * Functions are helpful in generalizing the program


Are all patterns recursive?

No, patterns with terms that are not based upon previous terms are not recursive. Example: i * i where i is the nth term of the pattern.


What are the merits and demerits of recursion?

Ans: Merits of recursion are: Mathematical functions, such as Fibonacci series generation can be easily implemented using recursion as compared to iteration technique. Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.


What has the author Anatolii Ivanovich Mal'tsev written?

Anatolii Ivanovich Mal'tsev has written: 'Algorithms and recursive functions'


Can you call predefined function recursively?

Guess you meant: can a recursive function call predefined functions? Answer: sure, why not.


Jntu 2-2 oops through java answers?

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


What are demerits of recursion?

Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.