Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Javascript Project : Factorial - Do While - While Loops
SUBMITTED BY:
Guest
DATE:
Dec. 29, 2013, 11:46 p.m.
FORMAT:
Text only
SIZE:
735 Bytes
Raw
Download
Tweet
HITS:
1300
Go to comments
Report
var dwinteger=1;
var dwtotal=0;
do
{
dwinteger=dwinteger+2;
dwtotal=dwtotal+dwinteger;
}
while (dwinteger<=99);
var winteger=1;
var wtotal=0;
while (winteger<=100)
{
winteger=winteger+1;
wtotal=wtotal+winteger
}
function factorial()
{
var f_input=prompt("Calculate the factorial of:");
var total=1;
var counter=1;
for (counter=1;counter<=f_input;counter++)
{
total=total*counter;
}
alert("Factorial " + f_input + ": " + total + '\n' + '\n' + '\n' +
"Do - While loop: Sum of all odd numbers from: 1-100: " + dwtotal + '\n' + '\n' + '\n' + "While loop: Sum of all numbers from: 1-100: " + wtotal);
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus