The algorithm initially writes a recursive static method to compute ln (n!) The value

Source: Internet
Author: User
Tags natural logarithm
Directly using the Math library public
static double log (double A)
Returns the natural logarithm (base e) of a double value. Special Cases:if The argument is a nan or less than zero and then the result is Nan. If The argument is positive infinity and then the result is positive infinity. If The argument is positive zero or negative zero and then the result is negative infinity.

The computed result must be within 1 ULP of the exact result. Results must be semi-monotonic. Parameters:a-A value returns:the value ln A, the natural logarithm of a.

public static double Logn (double n)
	{
		if (N = = 0 | | N = = 1) return 0.0;  The factorial of 0 and the factorial of 1 are 1
		else {
			return Math.log (N) +logn (N-1);}
		
	}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.