Pages

Sunday, August 7, 2011

write a loop that adds the numbers 1 to 100 and prints the result

Write a loop that adds the numbers 1 to 100 and prints the result?

1 comment:

  1. function print100()
    {
    var sum=0;
    for(i=1;i<=100;i++)
    {
    sum=sum+i;
    }
    document.write(sum);
    }
    print100();

    ReplyDelete