simple-recursion
Simple recursion example.
by robhortn
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<h1>Simple Recursion</h1>
<p>
Easy illustrations of simple examples of recursion (see what I did there?)
</p>
<div id="debug-output">
<p>.:: Debug output ::.</p>
</div>
CSS
#debug-output {
margin-top: 20px;
background-color: blue;
color: yellow;
padding: 8px;
font-family: 'Segoe UI', Consoloas, Courier;
}
JavaScript
function logit(strMsg) {
document.getElementById('debug-output').innerHTML += strMsg + '<br/>'
}
function fact(x) {
if (x == 1) {
return 1;
} else {
return x * fact(x-1);
}
}
logit(fact(5));