Thue-Morse: Difference between revisions

→‎{{header|Python}}: Add pair-wise concatenation
(→‎{{header|Kotlin}}: Alternative implementation)
(→‎{{header|Python}}: Add pair-wise concatenation)
Line 1,531:
>>> thue_morse_subs(20)
'01101001100101101001'
>>>
</lang>
 
===Python: By pair-wise concatenation===
<lang Python>
>>> def thue_morse(n):
... (v, i) = ('0', '1')
... for _ in range(0,n):
... (v, i) = (v + i, i + v)
... return v
...
>>> thue_morse(6)
'0110100110010110100101100110100110010110011010010110100110010110'
>>>
</lang>