Collatz conjecture, Syrucuse conjecture, (3n+1 problem, hailstone numbers...)

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
User avatar
ratwolf
Posts: 33
Joined: Fri Feb 12, 2021 1:00 am

Collatz conjecture, Syrucuse conjecture, (3n+1 problem, hailstone numbers...)

Post by ratwolf »

As I was lazy I just modified an old HP-67 program
If you are creative you can modify it by your own e.g., maximum, number of odd sequences etc.

Input a positive Integer and press R/S. The number of sequences is displayed in X if 1 had been reached :-)

Try 12, 19 or 27...

You are a hero if finding a positive integer which sequence is not reaching 1 :-)


Code: Select all

00 { 64-Byte Prgm }
01▸LBL "3n+1"
02 0
03 STO 00
04 INPUT "Start"
05▸LBL A
06 STO 01
07 1
08 -
09 X=0?
10 GTO C
11 1
12 STO+ 00
13 RCL 01
14 PSE
15 2
16 ÷
17 FP
18 X=0?
19 GTO B
20 RCL 01
21 3
22 ×
23 1
24 +
25 GTO A
26▸LBL B
27 RCL 01
28 2
29 ÷
30 GTO A
31▸LBL C
32 RCL 00
33 END
Attachments
3n+1.raw
(67 Bytes) Downloaded 3 times
Post Reply