Page 1 of 1

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

Posted: Sun Jun 06, 2021 9:35 pm
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