Given a number N, the task is to find the log value of the factorial of N i.e. log(N!).
Note: ln means log with base e.
Input: N = 2 Output: 0.693147 Input: N = 3 Output: 1.791759
Method -1: Calculate n! first, then take its log value.
Method -2: By using the property of log, i.e. take the sum of log values of n, n-1, n-2 …1.
ln(n!) = ln(n*n-1*n-2*…..*2*1) = ln(n)+ln(n-1)+……+ln(2)+ln(1)
Below is the implementation of the Method-2:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find geometric sum of the series using recursion
- Find HCF of two numbers without using recursion or Euclidean algorithm
- Program to find all Factors of a Number using recursion
- Find Maximum Level Sum in Binary Tree using Recursion
- Find the node with maximum value in a Binary Search Tree using recursion
- Sum of the series 1^1 + 2^2 + 3^3 + ..... + n^n using recursion
- Solving f(n)= (1) + (2*3) + (4*5*6) ... n using Recursion
- Tail Recursion
- Sum of even elements of an Array using Recursion
- Product of 2 Numbers using Recursion
- Traverse a given Matrix using Recursion
- Tail Recursion for Fibonacci
- Sort a stack using recursion
- Generating subarrays using recursion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ihritik