Bonfire: Factorialize a Number Difficulty: Level 1

I had to redo this one. It showed up correctly the first time, but apparently my answer was so far out in left field, that I got a false positive!

Instructions:

Return the factorial of the provided integer.

If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120f

Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

 

My solution:

function factorialize(num) {

var factor = 1;
for (i=1; i<=num; i++){
factor = factor * i ;
}

return factor;
}

factorialize(5);

Advertisements

One thought on “Bonfire: Factorialize a Number Difficulty: Level 1

  1. Pingback: Bonfire: Factorialize a Number Difficulty: Level 1 | Dinesh Ram Kali.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s