Skip to content
Onsite

Logarithm of Factorial

EasyP3Coding

Given an integer n, return the natural logarithm of n!, that is ln(n!), rounded to 4 decimal places.

Do not compute n! itself: it overflows long before n = 100. Use ln(a * b) = ln(a) + ln(b).

Example 1

Input
n = 1
Output
0

Example 2

Input
n = 2
Output
0.6931

Example 3

Input
n = 5
Output
4.7875

Constraints

  • 1 <= n <= 10^5

Hints

Run checks the 3 visible tests, Submit all 10.