(HP-65) Collatz Conjecture - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-65/67/97 Software Library (/forum-12.html) +--- Thread: (HP-65) Collatz Conjecture (/thread-14335.html) |
(HP-65) Collatz Conjecture - Dave Britten - 01-08-2020 07:03 PM Yeah, it's been done a million times before, but just for posterity... Basic premise: The Collatz Conjecture states that you can start from any positive integer; if it's even, divide it by 2, and if it's odd, multiply by 3 and add 1. Continue this sequence, and you will always eventually reach 1. Usage Enter a positive integer in X, press A, and the program will tell you the number of steps required to reach 1 starting from your number. If you set flag 1 before running the program, it will stop to display each number in the sequence. Press R/S to calculate the next number. Code: LBL 23 If you don't need the ability to set flag 1 to view the sequence, you can omit these four steps shortly after LBL 2 for a roughly 9% speed up: f, TF 1, R/S, NOP |