← Back to challenges

Is the Input Factorial of an Integer?

JavaScriptHardmathloopsvalidationrecursion

Instructions

Create a function to check if a given integer is a factorial of integer or not. The return value should be a boolean.

Examples

isFactorial(2) ➞ true
// 2 = 2 * 1 = 2!

isFactorial(27) ➞ false

isFactorial(24) ➞ true
// 24 = 4 * 3 * 2 * 1 = 4!

Notes

  • Input is a positive integer.
  • Alternatively, you can solve this with a recursive approach.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.