Java Algorithm Blue Bridge Cup (question + answer) number of briquettes

Source: Internet
Author: User

1. Number of briquettes (results fill in the blanks)

There was a heap of briquettes, piled into triangular pyramid. Specific:
1 on the first floor,
The second Layer 3 (arranged into triangles),
The third layer of 6 (arranged into triangles),
Fourth layer 10 (arranged into triangles),
....
If there are 100 floors, how many briquettes are there?

Please fill in the total number of briquettes.
Note: You should submit an integer, do not fill in any superfluous content or descriptive text.

1  Public class_1 briquettes Number {2     Public Static voidMain (string[] args) {3       intSum=0;4       intDangqian = 0;5        for(inti = 1; I <= 100; i++) {6Dangqian + =i;7Sum + =Dangqian;8       }9 System.out.println (sum);Ten    } One}

Run Result: 171700

Java Algorithm Blue Bridge Cup (question + answer) number of briquettes

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.