How to realize the summation of coins by java
This article will explain in detail how to realize the sum of coins in java. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
British monetary units include pounds, pounds and pennies, and there are eight coins in circulation:
1p, 2p, 5p, 10p, 20p, 50p, £1 (100p), £2 (200p)
Here is one of the possible ways to make up £2:
1 × £1 + 1 × 50p + 2 × 20p + 1 × 5p + 1 × 2p + 3 × 1p
There is no limit on the number of coins to be used. How many different ways are there to make up £2?
System.out.println (triangular_number)
Analysis:
Enumerate the number of triangles to determine whether his divisor is greater than 500, and if so, return directly. Pay attention to whether the following judgment is a square, if it is to subtract 1, for example, the divisor of 9 is 1, not 1, not 1.
This is the end of the article on "how to achieve the sum of coins in java". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.