Jump to content

Look-and-say sequence: Difference between revisions

Line 2,909:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
The function:
Custom Functions:
<lang Mathematica> LookAndSay[n_Integer?Positive]:=Map[Reverse,Tally/@Split@IntegerDigits@n,2]//Flatten//FromDigits</lang>
 
Thistakes function, which works foran arbitrary positive integersinteger, starts with `n` and generates the next member of the ‘Look and Say’ sequence.
 
The first example returns the first 13 numbers of the sequence starting with 1. Entering
Line 2,932:
11131221133112132113212221
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221<pre>
 
Entering 7:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.