4 ms·
0! = 1 is not hard to accept, since it follows a rule. You just need to look at it backwards. To get the previous factorial (Ni-1)! you need to divide the N! by
by smnplk 6y ago
0! = 1 is not hard to accept, since it follows a rule. You just need to look at it backwards. To get the previous factorial (Ni-1)! you need to divide the N! by N
4! = 24 ;; 24 / 4 = 6
3! = 6 ;; 6 / 3 = 2
2! = 2 ;; 2 / 2 = 1
1!= 1 ;; 1 / 1 = 1
0! = 1
- zests 6y agoEven funnier is how this roughly works for -1!
- Koshkin 6y agoThis looks even more natural from the programmer’s standpoint: reduction of a set of numbers by summation starts with 0, and reduction by multiplication, with 1; so, if the set is empty (has zero elements) the result is simply the starting number (0 or 1, respectively).
- _0ffh 6y agoAnd so in general the reduction of an empty list should always the neutral element of the operator.
- gcanyon 6y agoI was going to joke, "So you're saying -1! = 1/0" but then I thought I'd check Wikipedia first and that's exactly the reason they give for factorials of negatives being undefined, which spoils the joke.