← Back to challenges

Exact Factorial Bounds

PythonHardloopsnumbersvalidation

Instructions

Create a function that tests if a number is the exact upper bound of the factorial of n. If so, return a list 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.
  • A recursive version of this challenge can be found via this link.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.