Natural number sum in the recrusion using in javascript
<script>
function sumnaturalnumber(n){
if(n > 0){
return n + sumnaturalnumber(n - 1);
}else{
return n;
}
}
let n1 = parseInt(prompt("Enter the natural no which you want to sum"));
let result = sumnaturalnumber(n1);
console.log(result);
</script>
Thanks you for commenting your questions. I will see question and respond you.