1000! Number of digits and specific values [C #]

Source: Internet
Author: User

A. 1000! How many digits are there? Why?

First go to the Code to see at a glance

            int n = 1000;            double sum = 0;            for (int i = 1; i <= n; i++)                        {                sum = sum + Math.Log10(i);            }            Console.WriteLine("The '1000! has %{0}'s numbers.\n", (int)sum + 1);

Principles

For example: 1234 = 1.234*10 ^ 3

By referencing the logarithm, you can simply obtain the number of digits.

Log10 (a * 10 ^ x) = log10 (a) + x

Calculate 1000 again! Number of results

Log10 (1000 !) = Log10 (1000*999 *... 2*1) = log10 (1000) + log (999) +... + Log (1)

B. 1000! Specific value

2586 this is a huge number, which is obtained by countless computations in general.

You must use the multiplication of large numbers to complete the calculation.

The specific idea is to convert a number into a string and then perform multiplication on the string to obtain the result.

See: http://wenku.baidu.com/view/5623fcc14028915f804dc218.html for code

 

1000! A total of 2586 digits, as shown in the figure. That's pretty spectacular!

 

External Link

  • Factorial http://baike.baidu.com/view/245476.htm.
  • Logarithm http://baike.baidu.com/view/356.htm

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.