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

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.


Will the explicit formula find the same answer when using the recursive formula?

It is often possible to find an explicit formula that gives the same answer as a given recursive formula - and vice versa. I don't think you can always find an explicit formula that gives the same answer.


What is the definition of recursive?

The term recursive refers to the recurrence or repetition.


What is a recursive formula and what is it used for Geometric and Arithmetic?

A recursive definition is any definition that uses the thing to be defined as part of the definition. A recursive formula, or function, is a related formula or function. A recursive function uses the function itself in the definition. For example: The factorial function, written n!, is defined as the product of all the numbers, from 1 to the number (in this case "n"). For example, the factorial of 4, written 4!, is equal to 1 x 2 x 3 x 4. This can also be defined as follows: 0! = 1 For any "n" > 0, n! = n x (n-1)! For example, according to this definition, the factorial of 4 is the same as 4 times the factorial of 3. Try it out - apply the recursive formula, until you get to the base case. Note that a base case is necessary; otherwise, the recursion would never end.


What is recursive rule?

A recursive rule is one which can be applied over and over again to its own output

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.


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.


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.