# Factorialize a number help with 0 \[SOLVED\]

**URL:** <https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172>\
**Category:** General\
**Created:** [February 17, 2017, 12:45am UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172 "2017-02-17T00:45:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 17, 2017, 12:45am UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172/1 "2017-02-17T00:45:33Z")

</div>

Hi all, just working on some of the algorithms for FCC.

I’m working on factorializing a number and I’m not sure how to get this code to work with the number 0.

The code is probably wonky, but I’m pretty happy that it works for all but one number.

Edit: Got it! Thanks Cowwy!

---

<div class="post-metadata">

**Author:** ![Cowwy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cowwy/32/158666_2.png) [@Cowwy](https://forum.freecodecamp.org/u/Cowwy)\
**Post date:** [February 17, 2017, 12:51am UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172/2 "2017-02-17T00:51:18Z")

</div>

First off, divide by 0 is a no no. Okay in JavaScript as it will return infinity, but other languages will give you an divide by 0 warning.

```auto
result = num/num

```

It then jumps to the for loop which resets the **result variable** to 1;

To answer the question, you need some sort of decision making process when you encounter an input of 0 or 1; Something has to do with **if statement.** 🙂

Does that give you enough hints?

---

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 17, 2017, 12:54am UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172/3 "2017-02-17T00:54:32Z")

</div>

Thanks! 🙂

My original if statement wasn’t working

Edit: I fixed it! Thanks a bunch man

---

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 17, 2017, 12:59am UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172/4 "2017-02-17T00:59:23Z")

</div>

Nevermind! I got it and I am dumb ☹

Can’t use x = 0…

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:24pm UTC](https://forum.freecodecamp.org/t/factorialize-a-number-help-with-0-solved/88172/5 "2021-01-16T17:24:14Z")

</div>

Closed on January 16, 2021, 5:24pm UTC


