So I have this task where I'm going to create a function that calculates the faculty of a number and output the answer:

i.e faculty of 4 = 1*2*3*4 = 24.

This is my code so far, it's almost solved, but there is a detail that I'm missing which would make it all much simpler I suspect.

function fakultet(tall:int) { var teller:Number = 1; var number = tall*teller*(tall-1); while(teller <= tall) { teller++; trace(teller*number); } } fakultet(5);

This code will output the following numbers:

40

60

80

100

120 <-- And THAT is the only one number I want to see in the output window for "5" when I run my code.

That is the faculty of "5", so I want that last number for any given number I type in to be the only number to appear.

If I switch out "5" with "4", it will say 24 at the bottom. That is the number I want to come alone. Help is much appreciated.!

- lillemakken, 1st post.