King Interview Question: How would you implement a fac... | Glassdoor

Interview Question

Data Scientist Interview Barcelona (Spain)

How would you implement a factorial function with no for

  loops?
Answer

Interview Answer

1 Answer

1

Recursion

function factorial(n) {
  if n = 0 return 1
  else return n * factorial(n-1)
}

Anonymous on Jul 6, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.