Look-and-say sequence: Difference between revisions

Content deleted Content added
Line 2,909: Line 2,909:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{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>
<lang Mathematica> LookAndSay[n_Integer?Positive]:=Map[Reverse,Tally/@Split@IntegerDigits@n,2]//Flatten//FromDigits</lang>


This function, which works for arbitrary positive integers, starts with `n` and generates the next member of the sequence.
takes an arbitrary positive integer, 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
The first example returns the first 13 numbers of the sequence starting with 1. Entering
Line 2,932: Line 2,932:
11131221133112132113212221
11131221133112132113212221
3113112221232112111312211312113211
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221
1321132132111213122112311311222113111221131221<pre>


Entering 7:
Entering 7: