# Answer to Question #16000 in Action Script | Flash | Flex | ColdFusion for wwktnnr

Question #16000

Given that n refers to a positive int use a while loop to compute the sum of the cubes of the first n counting numbers, and associate this value with total . Use no variables other than n , k , and total .

Expert's answer

onSelfEvent (load) {

total=0;

n=0;

k=0;

a = 1;

while (a++ < 5) {

total+=Math.pow(a,3);

trace("Nmmber "+a+"^3= "+Math.pow(a,3));

}

trace("Total="+total);

}

total=0;

n=0;

k=0;

a = 1;

while (a++ < 5) {

total+=Math.pow(a,3);

trace("Nmmber "+a+"^3= "+Math.pow(a,3));

}

trace("Total="+total);

}

## Comments

## Leave a comment