# Q = 114 # 458 successful iterations INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q #INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q # 11 #CLEAR S # s <= (x > 0) assume empty #CLEAR L assume empty #CLEAR M assume empty INCREASE M REPEAT X TIMES ( REPEAT M TIMES ( REPEAT L TIMES ( CLEAR M INCREASE S ) INCREASE L ) ) PRINT X REPEAT Q TIMES ( REPEAT S TIMES ( # skips iterations 10x faster if there are a lot to skip REPEAT Q TIMES ( # repeat 11 times 11 times: 121 times # if x > 1 REPEAT S TIMES ( # o: store x / 2 CLEAR O # a: even # b: odd # c: pass-through INCREASE A #CLEAR C always clear, used as pass-through REPEAT X TIMES ( # flip-flop a/b REPEAT A TIMES ( CLEAR A INCREASE C ) REPEAT B TIMES ( CLEAR B INCREASE A INCREASE O ) REPEAT C TIMES ( CLEAR C INCREASE B ) ) # if a REPEAT A TIMES ( CLEAR A # copy x <= o CLEAR X # check only needed in this branch! # other branch always increases value of x # check x/2 > 1 (for next iteration) CLEAR S # s <= (x > 0) CLEAR L # L is set to 2 after the loop, cannot assume empty #CLEAR M assume empty, if not empty then we shouldnt be inside the loop # Better x > 1 alg! INCREASE M REPEAT O TIMES ( REPEAT M TIMES ( REPEAT L TIMES ( CLEAR M INCREASE S ) INCREASE L ) INCREASE X # copy x <= o ) ) # else (if b) REPEAT B TIMES ( CLEAR B # x += 0.5x # o = 3x-3 REPEAT O TIMES ( INCREASE X INCREASE O INCREASE O INCREASE O INCREASE O INCREASE O ) # o = 3x INCREASE O INCREASE O INCREASE O # x += 1 INCREASE X # o += 1 INCREASE O # print o: 3x+1 PRINT O ) # mandatory print PRINT X ) ) ) )