Example of Java method for calculating the number of black holes

This paper describes the method of calculating the number of black holes in Java. Share with you for your reference, as follows:

Any 5-digit number, such as 34256, can be scrambled and rearranged to obtain a maximum number: 65432 and a minimum number of 23456. Find the difference between the two numbers and get: 41976. Repeat the above process again (if it is less than 5 digits, fill 0 in the front). In this way, the number will fall into a circular circle (called digital black hole).

For example, the number just now will fall into the circle of: [829627593395461974].

Please write a program to find all possible 5-digit circular circles and output them. Each circular circle occupies 1 line. If the 5 digits are all the same, the cycle is [0], which can be ignored. The output format of the loop is modeled as follows:

[82962,61974]

The sequence of numbers can be ignored.

Test. java:

Operation results:

For more information about Java algorithms, readers who are interested can see the topics on this site: summary of Java mathematical operation skills, tutorial on Java data structure and algorithms, summary of Java DOM node skills, summary of java file and directory operation skills, and summary of Java cache operation skills

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>