The Squaring Sequence Each term in the squaring sequence, \$x_n\$, is created by taking \$x_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x_1 = 1111\$. Squaring this yields \$1234321\$, so \$x_2 = 1234\$
The first few terms are:
1111
1234
1522
2316
5363
...


The Challenge
Your task is to, given a non-negative integer \$n\$, calculate \$x_n\$. You may submit a full program which performs I/O, or a function which takes \$n\$ as a parameter.
Your solution can be zero or one indexed, as long as you specify which.
Because all the terms in this sequence are shorter than 5 digits, your code should be as short as possible too. Standard code-golf loopholes apply.
May the best golfer win!

Test Cases
Note: These are 1-indexed.
1   -&gt; 1111
8   -&gt; 6840
15  -&gt; 7584
20  -&gt; 1425
80  -&gt; 4717
JavaScript (ES7), 44 43 36 bytes

f=n=&gt;--n?(f(n)**2+f).slice(0,4):1111


This is a great example of abusing type coercion: ** converts both its arguments to numbers, and + converts both its arguments to strings unless they're both numbers. This means that f(n)**2+f first converts f(n) to a number and squares it, then concatenates the result with the string representation of f. We can then use .slice to retrieve the first 4 chars of the string.

Here are a few alternate approaches that don't use strings:

f=(n,x=1111)=&gt;x&lt;1e4?--n?f(n,x*x):x:f(n,x/10|0)
f=n=&gt;--n?(x=f(n))*x/(x&gt;3162?1e4:1e3)|0:1111


Test snippet



let f=n=&gt;--n?(Math.pow(f(n),2)+f).slice(0,4):1111
&lt;input id=I type="number" step="1" min="1" value="1"&gt;&lt;button onclick="console.log(f(I.value))"&gt;Run&lt;/button&gt;




Note: this uses Math.pow because ** isn't supported in all browsers.