Bit manipulation is often used to make operations in assembly blazing fast. In TI-BASIC, the bits of a number can't be manipulated separately. Often, then, TI-BASIC programmers instead use lists of booleans.

**Code:** ```
{1,1,0,1,1,1,0,0,1}→L₁
```

{0,1,1,1,0,0,1,0,0}→L₂

not(L₁ # {0,0,1,0,0,0,1,1,0}

L₁(5 # 1

L₁ and L₂ # {0,1,0,1,0,0,0,0,0}

L₁ or L₂ # {1,1,1,1,1,1,1,0,1}

L₁ and not(L₂ # {1,0,0,0,1,1,0,0,1}

max(L₁ and not(L₂ # 1

L₁ xor L₂ # {1,0,1,0,1,1,1,0,1}

But there's a faster way. Instead of using list positions 1 through 9 to store the bits, use the first 9 primes, and multiply them all together into a squarefree integer. Here are the corresponding operations with squarefree-integer lists:

**Code:** ```
{2,3,5,7,11,13,17,19,23}→L₆ # first 9 primes
```

prod(L₆^L₁→A # 2*3*7*11*13*23

prod(L₆^L₂→B # 3*5*7*17

223092870/A # 5*17*19

not(remainder(A,7 # 1

gcd(A,B # 3*7

lcm(A,B # 2*3*...*17*23

A/gcd(A,B # 2*11*13*23

remainder(B,A # some nonzero value

gcd(A,B):A/AnsB/Ans # 2*5*11*13*17*23

Note especially the speed of the asymmetric set difference "remainder(B,A", which takes about 4 ms compared to over 20 for the corresponding boolean-list operations. But all of the operations are fast: gcd( and lcm( take 8 ms at most, which is significantly faster than using boolean-lists.

9 bits is well within the "integer" range of TI's floats: the largest number, representing a list of ones, is 223092870 ~= 2*10^8. This method of storing bit lists as squarefree integers can be extended to 11 bits by just using more primes (2*...*31 is 200560490130, which has the maximum of 12 digits). Beyond that, lists of bits can be split up into nice chunks of 8 or 9, stored as elements in a list, and the gcd( or whatever operation can be vectorized over the list.

Will update with full explanation and timings.

EDIT: Looks like gcd( is much slower than I thought. Worst case is around 65 ms, so it isn't a viable alternative. Only remainder( (5 ms or so worst case) seems useful out of these operations.