Post Reply 
(12C) 3n + 1 conjecture
07-06-2018, 07:13 PM (This post was last modified: 07-06-2018 07:21 PM by Dieter.)
Post: #3
RE: (12C) 3n + 1 conjecture
(07-06-2018 10:16 AM)Gamo Wrote:  This program allows to test the 3n + 1 conjecture.
...
17 R/S --> 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1

Program: Collatz conjecture

What? More than 30 steps? And even R0 is used? Waaaayyyy too complicated. ;-)

Code:
01  FIX 0
02  2
03  ÷
04  FRAC
05  x=0?    // check if n was even, n/2 now is in LastX
06  GTO 13
07  LstX    // for odd n...
08  6
09  *       // ...calculate 6*n/2 = 3n...
10  1
11  +       // ...+1
12  1/x     // this moves 3n+1 to LastX
13  1
14  LstX    // at this point LastX is either n/2 (if n was even) or 3n+1 (if n was odd)
15  x<=y?
16  GTO 00  // quit if n is 1 (or less)
17  PSE     // else display new n
18  GTO 01  // and repeat

Hint: if you want to check if n is even there is no need to check if 2*frac(n/2) is zero. Testing frac(n/2) will do. This again means that n/2 still is in LastX, so 6*LastX yields 3*n....

Still too long? Replace the final lines 13...18 with LstX GTO 00. The numbers are then displayed with [R/S].

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) 3n + 1 conjecture - Gamo - 07-06-2018, 10:16 AM
RE: (12C) 3n + 1 conjecture - Thomas Klemm - 07-06-2018, 06:59 PM
RE: (12C) 3n + 1 conjecture - Dieter - 07-06-2018, 07:25 PM
RE: (12C) 3n + 1 conjecture - Dieter - 07-06-2018 07:13 PM
RE: (12C) 3n + 1 conjecture - Joe Horn - 07-06-2018, 09:50 PM
RE: (12C) 3n + 1 conjecture - Dieter - 07-07-2018, 07:36 AM
RE: (12C) 3n + 1 conjecture - Thomas Klemm - 07-06-2018, 10:31 PM
RE: (12C) 3n + 1 conjecture - Joe Horn - 07-07-2018, 03:10 AM
RE: (12C) 3n + 1 conjecture - Gamo - 07-07-2018, 01:51 AM
RE: (12C) 3n + 1 conjecture - Thomas Klemm - 07-07-2018, 08:37 AM
RE: (12C) 3n + 1 conjecture - Joe Horn - 07-07-2018, 02:24 PM
RE: (12C) 3n + 1 conjecture - Dieter - 07-07-2018, 04:57 PM
RE: (12C) 3n + 1 conjecture - Joe Horn - 07-07-2018, 07:04 PM



User(s) browsing this thread: 1 Guest(s)