how to Create Javascript Recursive function

how to Create Javascript Recursive function


<html>
<head>
<title>
THis is recursive function example
</title>
<script type="text/javascript" language="javascript">
var s=window.prompt("enter the no ","");
s=parseInt(s);

function rec(s)
{
if(s==1)
{
return 1;

}
else
{
return s*rec(s-1);
}
}
function show()
{
var t=rec(s);
document.write("the factorial of  a no is "+t);
}
</script>
</head>
<body onload="show()">
</body>
</html>

No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

how to post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header

how to post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header  ...

Popular Posts