' 2020-07-09 Write up from reply I left at QB64 forum yesterday
' ref: https://www.qb64.org/forum/index.php?topic=2789.msg120521#msg120521
' here is essence (((N + 1) / 2) * 3) - 1 = (3*N + 1) / 2 is New Rule for Odd
' here is new limit (32766 / 3) * 2
' 2020-07-09 A dream I had this morning to change 2 rules into 1 (almost) in order to simplify
' the Collatz sequence into the significant sequence of ascending odd numbers.
' What do they look like in terms of prime numbers?
_TITLE "Collatz Collapse 2020-07-09" CONST topLimit
= (32766 / 3) * 2 'just integers today 1 PRINT "The highest number Interger Type can handle is"; topLimit;
"," PRINT "If our test number wanders up there we must cut the run short." PRINT "Go ahead try 20,000 it is over 1/3 of Integer Type Limit!" INPUT "(0 quits) Enter a number to try New Collatz Sequencer "; n
done = 0: odd = 0: even = 0: l = 1
sAppend cSeq$
(), "Starting number is" + STR$(n
) WHILE n
MOD 2 = 0 'drop down and give me an odd number of pushups n = n \ 2
s$ = s$ + " odd": l = l + 1
n = (((n + 1) / 2) * 3) - 1
odd = odd + 1
s$ = s$ + " hit limit, end of run.": done = 1
s$ = s$ + " even": l = l + 1
n = n \ 2: even = even + 1
WHILE n
MOD 2 = 0 'drop down and give me an odd number of pushups n = n \ 2
sAppend cSeq$(), s$
sAppend cSeq$(), s$
even = even + 1
sAppend cSeq$(), "------------------------------------------------------------------"
s$
= STR$(odd
) + " odd steps were taken to create this sequence.": sAppend cSeq$
(), s$
display cSeq$()
IF ub
- lb
+ 1 < 21 THEN top
= ub
ELSE top
= lb
+ 19 CLS:
PRINT "press any key to quit scroller..." IF row
> ub
- 19 THEN row
= ub
- 19 'prevent over scrolling IF prevrow
<> row
THEN 'look for a change in row value CLS:
PRINT "press any key to quit scroller..." prevrow = row 'store previous row value