Anonymous user
Look-and-say sequence: Difference between revisions
→{{header|Mathematica}}/{{header|Wolfram Language}}
Not a robot (talk | contribs) (Add Draco) |
|||
Line 2,910:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Custom Functions:
<lang Mathematica>
This function, which works for arbitrary positive integers, starts with `n` and generates the next member of the sequence.
The first example returns the first 13 numbers of the sequence starting with 1. Entering
<lang Mathematica>FromDigits /@ LookAndSay[13] // Column▼
returns
<pre style='height:15em;overflow:scroll'>1
Line 2,934:
1321132132111213122112311311222113111221131221
Entering 7:
<lang Mathematica>NestList[LookAndSay, 7, 12] // Column</lang>
generates:
<pre style='height:15em;overflow:scroll'>7
17
1117
|