1 to 100 million of the natural number, the sum of the numbers after the split of all numbers

Source: Internet
Author: User

1 to 100 million of the natural number, the sum of all the number of split numbers, such as 286 split into 2, 8, 6, such as 1 to 11 after splitting the sum of the numbers 1 + ... + 9 + 1 + 0 + 1 + 1

/*** 1 to 100 million of the natural number, the sum of all the number of split numbers, * such as 286 split into 2, 8, 6, * such as 1 to 11 after splitting the sum of the numbers + + 1 + ... + 9 + 1 + 0 + 1 + 1 *@paramargs*/     Public Static voidMain (string[] args) {/*** Thinking analysis * single digit: 10 digits: Hundreds: Thousands: thousand digits: 100,000 digits: Million dollar number: Chiwan: Billion*/        inta=1+2+3+4+5+6+7+8+9;//a=45        intaa=10+a+2*10+a+3*10+a+4*10+a+5*10+a+6*10+a+7*10+a+8*10+a+9*10+a;//=10* (1+2+3+4+5+6+7+8+9) +9a;        intaaa=100+aa+2*100+aa+3*100+aa+4*100+aa+5*100+AA+6*100+AA+7*100+AA+8*100+AA+9*100+AA;//=100A+9AA        intaaaa=1000+aaa+2*1000+aaa+3*1000+aaa+4*1000+aaa+5*1000+AAA+6*1000+AAA+7*1000+AAA+8*1000+AAA+9*1000+AAA;//=1000a+9aaa        intaaaaa=10000+aaaa+2*10000+aaaa+3*10000+aaaa+4*10000+aaaa+5*10000+AAAA+6*10000+AAAA+7*10000+AAAA+8*10000+AAAA+9*10000+AAAA;//=10000a+9aaaa;        intaaaaaa=100000+aaaaa+2*100000+aaaaa+3*100000+aaaaa+4*100000+aaaaa+5*100000+AAAAA+6*100000+AAAAA+7*100000+AAAAA+8*100000+AAAAA+9*100000+AAAAA;//=100000a+9aaaaa;        intaaaaaaa=1000000+aaaaaa+2*1000000+aaaaaa+3*1000000+aaaaaa+4*1000000+aaaaaa+5*1000000+aaaaaa+6*1000000+AAAAAA+7*1000000+AAAAAA+8*1000000+AAAAAA+9*1000000+AAAAAA;//=1000000a+9aaaaa;Long aaaaaaaa= ((10000000l*a) + (9l*aaaaaaa)); intAaaaaaaaa=1;        System.out.println (a);        SYSTEM.OUT.PRINTLN (AA);        System.out.println (AAA);        System.out.println (AAAA);        System.out.println (AAAAA);        System.out.println (AAAAAA);        System.out.println (AAAAAAA);        System.out.println (AAAAAAAA);        System.out.println (AAAAAAAAA); Longsum=a* (1+10+100+1000+10000+100000+1000000+10000000) +9l* (A+AA+AAA+AAAA+AAAAA+AAAAAA+AAAAAAA) +aaaaaaaaa; SYSTEM.OUT.PRINTLN (sum);

The output is:

4585512195154755184279521085155234766395256289755512820759751

Online to see the topic, you try to write.

1 to 100 million of the natural number, the sum of the numbers after the split of all numbers

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.