"Practice" Korazim questions

Source: Internet
Author: User

The 3n+1 problem is a simple, interesting and unsolved mathematical problem. The problem was raised by Collatz in 1937. The Korazim problem (Collatz problem) is also called hailstone problem, 3n+1 problem, Hassealgorithm problem, Kakutani algorithm problem, Thwaites conjecture or Ulam problem. The problem is as follows: (1) Enter a positive integer n, (2) If N=1 ends, (3) if n is odd, n becomes 3n+1, otherwise n becomes N/2; (4) Moves to step (2). The special point of the Korazim problem is that, although it is easy to clarify the problem, it is still not guaranteed that the algorithm for this problem will work for all possible inputs-that is, no one has proven that the process terminates for all positive integers. For example: n=9, there are 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
PublicClassCollatz {/*** Collatz Questions *@paramNumber*/PublicStaticvoid Collatzq (IntNumber) {String result = "";int TMP =NumberWhileTrue){if (tmp = = 1) {result = result + "Over"; SYSTEM.OUT.PRINTLN (result);Break; }Elseif (TMP <= 0{SYSTEM.OUT.PRINTLN ("the number is Error!!!")); break;} else { if (tmp% 2 = = 0) {tmp = TMP/2;} else {tmp = 3 * tmp + 1;} result = result + tmp + "\ T";}}} public static void main (string[] args) {for (int num = 0; num < num++) {Collatz. COLLATZQ (num); } }}

The number is Error!!! Over1    Over10    5    8    4    2    1    Over2    1    Over16    8    4    2    1    Over3    5 8 4 2    1 Over22 11 34 17 52 26 5 8 4 2 1 Over4 2 1 Over28 7   -Ten-5-8 4-2-1 
Reference: http://www.xuebuyuan.com/2025609.html

"Practice" Korazim questions

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.