O'Reilly logo
  • ninjew1 thinks this is interesting:

Example 4-11. A factorial written with the counting-up approach


Cover of Introducing Elixir


You really don't need to use three parameters/variables to accomplish this. If you decrement n and calculate the new result as the second parameter, while defaulting it to 1, you can drop this down to 2 parameters. factorial(n-1, n*result).