Task

Create a Thue-Morse sequence.



See also
   YouTube entry: The Fairest Sharing Sequence Ever
   YouTube entry: Math and OCD - My story with the Thue-Morse sequence
   Task: Fairshare between two and more


/* Find the N'th digit in the Thue-Morse sequence */
proc nonrec tm(word n) byte:
    word n2;
    n2 := n;
    while n2 ~= 0 do
        n2 := n2 >> 1;
        n := n >< n2
    od;
    n & 1
corp
 
/* Print the first 64 digits */
proc nonrec main() void:
    byte i;
    for i from 0 upto 63 do
        write(tm(i):1)
    od
corp