Recursion: Exact Factorial Bounds

Published by Deep Xavier in

Create a recursive 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

  • You are expected to solve this challenge via recursion.
  • You can check on the Resources tab for more details about recursion in Java.
  • You might want to check the non-recursive version of this challenge in here.
  • If you find recursion to be fun, check out this collection.
Watch a quick demo on how Edabit works.