Jump to content

Thue-Morse: Difference between revisions

m
→‎using functions: used a template for the output section.
m (→‎using functions: used a template for the output section.)
Line 1,480:
<lang rexx>/*REXX pgm generates & displays the Thue─Morse sequence up to the Nth term (inclusive). */
parse arg N . /*obtain the optional argument from CL.*/
if N=='' | N=="," then N=80 80 /*Not specified? Then use the default.*/
$= /*the Thue─Morse sequence (so far). */
do j=0 to N /*generate sequence up to the Nth item.*/
$= $ || $weight(j) // 2 /*append the item to the Thue─Morse seq*/
end /*j*/
say $
Line 1,490:
$pop: return length( space( translate( arg(1), , 0), 0) ) /*count 1's in number.*/
$weight: return $pop( x2b( d2x( arg(1) ) ) ) /*dec──►bin, pop count*/</lang>
'''{{out|output''' |text=&nbsp; when using the default input:}}
<pre>
01101001100101101001011001101001100101100110100101101001100101101001011001101001
</pre>
 
===using in-line code===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.