Jump to content

Thue-Morse: Difference between revisions

Add Cowgol
(Add BQN)
(Add Cowgol)
Line 648:
0110100110010110100101100110100110010110011010010110100110010110
</pre>
 
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
 
# Find the N'th digit in the Thue-Morse sequence
sub tm(n: uint32): (d: uint8) is
var n2 := n;
while n2 != 0 loop
n2 := n2 >> 1;
n := n ^ n2;
end loop;
d := (n & 1) as uint8;
end sub;
 
# Print the first 64 digits
var i: uint32 := 0;
while i < 64 loop
print_char('0' + tm(i));
i := i + 1;
end loop;
print_nl();</lang>
{{out}}
<pre>0110100110010110100101100110100110010110011010010110100110010110</pre>
 
=={{header|Crystal}}==
2,115

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.