rgebo21
1
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!
Cowwy
2
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.
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?
1 Like
rgebo21
3
Thanks! 
My original if statement wasn’t working
Edit: I fixed it! Thanks a bunch man
rgebo21
4
Nevermind! I got it and I am dumb 
Can’t use x = 0…
1 Like