sum of natural number using javascript

technical talkiess
0

sum of natural number using javascript


 <script>

var number = parseInt(prompt("Please Enter the number."));

var sum = 0;

for(var i=1;i<=number;i++){

sum += i;

}

alert(sum);

</script>

Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)