i have to do a few simple calculations for my javascript programming class and i've reached a part that i'm stuck at.
i have an array, made up of a user-determined number of user-determined numbers. what they want me to do is write code to calculate the factorial of a user determined position (ie. the factorial of position 3 [ie. position3*position2*position1]).
what i have now is the extremely iffy code:
Code:
var i = window.prompt("Factorial from what position?");
for (x=0;x<=i;x=x+1){
product=myarrayname[x]*myarrayname[x+1]
}
document.write("product of a factorial done from position " + (i) + ":<br />")
document.write(product);
i know that the way they are multiplied right now doesn't make sense, but i have been trying to work it all different kinds of ways.
i have to turn it in in an hour or so, quick responses = sexual favor!!! haha
Bookmarks