(16C) Collatz conjecture - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (16C) Collatz conjecture (/thread-17844.html) |
(16C) Collatz conjecture - wynen - 12-22-2021 01:41 PM Starting with any positive integer, repeat the following operation - If the number is even, divide it by two. - If the number is odd, triple it and add one. The conjecture is, this process will always reach the number one. The HP16-C has the shift an rotate operations in integer modes, which are useful for this kind of programs. Code: f SR Code: f SL Show the Collatz sequence: Code: 001 43,22, C g LBL C Usage: enter a positive number GSB C Example: 7 GSB C shows 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 0 RE: (16C) Collatz conjecture - Maximilian Hohmann - 12-22-2021 04:08 PM Hello! For more background you can watch this video: https://www.youtube.com/watch?v=094y1Z2wpJg I saw it by chance a couple of weeks ago (not really by chance as I watch nearly all videos from Derek Muller). Regards Max |