DEV Community

loading...

Discussion on: OOP vs functional programming

Collapse
veciz profile image
Berkan Çetinkaya

This is more like OOP vs Procedural comparison indeed :)
By the way you can use recursion for your factorial function

function factorial(x) {
  return x === 0 ? 1 : x * factorial(x - 1);
}

Nice article :)

Collapse
klamserdev profile image
Jakob Klamser Author

Thanks for the feedback. I linked to geeksforgeeks for more details on the implementation possibilities for a factorial. I decided to go for the iterative approach because I didn’t want to introduce recursion in this article 😁

Collapse
veciz profile image
Berkan Çetinkaya

Yep, just seen it :) I was thinking to opposite, factorial is good chance to show off the recursion :)