Exact Factorial Bounds

Published by Matt in

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

Examples

is_exact(6) ➞ [6, 3]

is_exact(24) ➞ [24, 4]

is_exact(125) ➞ "Not exact!"

is_exact(720) ➞ [720, 6]

is_exact(1024) ➞ "Not exact!"

is_exact(40320) ➞ [40320, 8]

Notes

  • There will be no exceptions to handle, all inputs are positive integers.
  • Optionally, you can solve this challenge via recursion (if you're comfortable with it).
Watch a quick demo on how Edabit works.