0% found this document useful (0 votes)
50 views

Recursive Functions

Recursive functions are functions that call themselves. The example provided calculates the factorial of a number recursively by having the function call itself with decreasing arguments until it reaches 1, at which point it returns the argument and the successive function calls multiply the returns together to calculate the factorial. The output displays that the factorial of 4, calculated by the recursive function, is 24.

Uploaded by

rina mahure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Recursive Functions

Recursive functions are functions that call themselves. The example provided calculates the factorial of a number recursively by having the function call itself with decreasing arguments until it reaches 1, at which point it returns the argument and the successive function calls multiply the returns together to calculate the factorial. The output displays that the factorial of 4, calculated by the recursive function, is 24.

Uploaded by

rina mahure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Recursive Functions:

Recursion refers to a situation, wherein functions call themselves. In other words, there is a call
to a specific function from within the same function. Such functions are known as Recursive
Functions.

Example:
<html>
<head><title></title>
<script language="javascript">
function fun1(number)
{
if(number>1)
{
return number*fun1(number-1)
}
else
{
return number
}
}
var a
a=fun1(4)
document.write("The factorial of a number is "+a)
</script>
</body>
</body>
</html>

Output:
The factorial of a number is 24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy