Blue Bridge number briquettes JAVA

A pile of briquettes, a triangular pyramid-shaped pile. In particular:
The first put a layer,
the second layer 3 (arranged in a triangle),
the third layer 6 (arranged in a triangle),
the fourth layer 10 (arranged in a triangle),
...
If a total of 100 layers, total how many briquettes?

Please fill in the total number of briquettes purpose digital representation.
Note: Your submission should be an integer, do not fill in any extra content or descriptive text.
Thinking: Title of law (layers x (the number of layers + 1) / 2)

public static void main(String[] args) {
		long count = 0;
		for (long i = 1; i <= 100; i++) {
			count += i * (i + 1) / 2;
		}
		System.out.println(count);
	}

Small Theater: find your purpose, then the method will follow.

Published 108 original articles · won praise 113 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43771695/article/details/104610690