Exact Factorial Bounds

Published by Deep Xavier in

Create a function that tests if a number is the exact upper bound of the factorial of n. If so, return an array of the exact factorial bound and n, or otherwise, an empty array.

Examples

isExact(6) ➞ [6, 3]

isExact(24) ➞ [24, 4]

isExact(125) ➞ []

isExact(720) ➞ [720, 6]

isExact(1024) ➞ []

isExact(40320) ➞ [40320, 8]

Notes

  • Alternatively, you can solve this challenge via recursion.
  • A recursive version of this challenge can be found via this link.
Watch a quick demo on how Edabit works.