We’re rewarding the question askers & reputations are being recalculated! Read more.

4 added 49 characters in body

## Powershell, 7373 55 bytes

Huge thanks to TimmyD for shaving off 18 bytes!

Code:

$A=1111;1..($n=4)|%{[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A  for($A=1111;$args---1;$A=-join"$(+$A*$A)"[0..3]){}$A

$A=1111;1..($n=2)|%{[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A $n is n in xn-1

Explanation and exploded code:

$A=1111 #starting number$n=4                               #n in formula
for($i=0;$i -lt $n;$i++)          #loop n times
{
[string]$B=[math]::pow($A,2)   #create a new string $B and set it to$A raised to the power of 2
$A=$B.substring(0,4)           #set $A to the first 4 characters of$B
}
$A #print$A


Some notes:

• Powershell lets you assign variables in the same statements where you reference them. For example, 1..($n=4)|% will set$n to 4 and then start a loop that runs $n times. 1 can be changed to any integer and it will loop$n-[your integer]+1 times.
• The default data type when using [math]:: in Powershell is a double. In the code above, we have to explicitly cast $B to a string so that we can call .substring() on it because there is no .substring() function for doubles in Powershell. ## Powershell, 73 bytes Code: $A=1111;1..($n=4)|%{[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A


$n is n in xn-1 Explanation and exploded code: $A=1111                            #starting number
$n=4 #n in formula for($i=0; $i -lt$n;$i++) #loop n times { [string]$B=[math]::pow($A,2) #create a new string$B and set it to $A raised to the power of 2$A=$B.substring(0,4) #set$A to the first 4 characters of $B }$A                             #print $A  Some notes: • Powershell lets you assign variables in the same statements where you reference them. For example, 1..($n=4)|% will set $n to 4 and then start a loop that runs$n times. 1 can be changed to any integer and it will loop $n-[your integer]+1 times. • The default data type when using [math]:: in Powershell is a double. In the code above, we have to explicitly cast $B to a string so that we can call .substring() on it because there is no .substring() function for doubles in Powershell.

## Powershell, 73 55 bytes

Huge thanks to TimmyD for shaving off 18 bytes!

Code:

for($A=1111;$args---1;$A=-join"$(+$A*$A)"[0..3]){}$A $A=1111;1..($n=2)|%{[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A

$n is n in xn-1 Explanation and exploded code: $A=1111                            #starting number
$n=4 #n in formula for($i=0; $i -lt$n;$i++) #loop n times { [string]$B=[math]::pow($A,2) #create a new string$B and set it to $A raised to the power of 2$A=$B.substring(0,4) #set$A to the first 4 characters of $B }$A                             #print $A  Some notes: • Powershell lets you assign variables in the same statements where you reference them. For example, 1..($n=4)|% will set $n to 4 and then start a loop that runs$n times. 1 can be changed to any integer and it will loop $n-[your integer]+1 times. • The default data type when using [math]:: in Powershell is a double. In the code above, we have to explicitly cast $B to a string so that we can call .substring() on it because there is no .substring() function for doubles in Powershell.
3 added 528 characters in body

## Powershell, 73 bytes

Code:

$A=1111;1..($n=4)|%{$A;[string]$B=[math][string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A  $n is n in xn-1

Explanation and exploded code:

$A=1111 #starting number$n=4                               #n in formula
for($i=0;$i -lt $n;$i++)          #loop n times
{
$A #print$A
[string]$B=[math]::pow($A,2)   #create a new string $B and set it to$A raised to the power of 2
$A=$B.substring(0,4)           #set $A to the first 4 characters of$B
}
$A #print$A


Some notes:

• Powershell lets you assign variables in the same statements where you reference them. For example, 1..($n=4)|% will set$n to 4 and then start a loop that runs $n times. 1 can be changed to any integer and it will loop$n-[your integer]+1 times.
• The default data type when using [math]:: in Powershell is a double. In the code above, we have to explicitly cast $B to a string so that we can call .substring() on it because there is no .substring() function for doubles in Powershell. ## Powershell, 73 bytes $A=1111;1..($n=4)|%{$A;[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)}


$n is n in xn-1 Explanation and exploded code: $A=1111                            #starting number
$n=4 #n in formula for($i=0; $i -lt$n;$i++) #loop n times {$A                             #print $A [string]$B=[math]::pow($A,2) #create a new string$B and set it to $A raised to the power of 2$A=$B.substring(0,4) #set$A to the first 4 characters of $B }  ## Powershell, 73 bytes Code: $A=1111;1..($n=4)|%{[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)};$A


$n is n in xn-1 Explanation and exploded code: $A=1111                            #starting number
$n=4 #n in formula for($i=0; $i -lt$n;$i++) #loop n times { [string]$B=[math]::pow($A,2) #create a new string$B and set it to $A raised to the power of 2$A=$B.substring(0,4) #set$A to the first 4 characters of $B }$A                             #print $A  Some notes: • Powershell lets you assign variables in the same statements where you reference them. For example, 1..($n=4)|% will set $n to 4 and then start a loop that runs$n times. 1 can be changed to any integer and it will loop $n-[your integer]+1 times. • The default data type when using [math]:: in Powershell is a double. In the code above, we have to explicitly cast $B to a string so that we can call .substring() on it because there is no .substring() function for doubles in Powershell.
2 added 403 characters in body

## Powershell, 73 bytes

$A=1111;1..($n=4)|%{$A;[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)}  $n is n in xn-1

Explanation and further golfing forthcoming.exploded code:

$A=1111 #starting number$n=4                               #n in formula
for($i=0;$i -lt $n;$i++)          #loop n times
{
$A #print$A
[string]$B=[math]::pow($A,2)   #create a new string $B and set it to$A raised to the power of 2
$A=$B.substring(0,4)           #set $A to the first 4 characters of$B
}


## Powershell, 73 bytes

$A=1111;1..($n=4)|%{$A;[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)}  $n is n in xn-1

Explanation and further golfing forthcoming.

## Powershell, 73 bytes

$A=1111;1..($n=4)|%{$A;[string]$B=[math]::pow($A,2);$A=$B.substring(0,4)}  $n is n in xn-1

Explanation and exploded code:

$A=1111 #starting number$n=4                               #n in formula
for($i=0;$i -lt $n;$i++)          #loop n times
{
$A #print$A
[string]$B=[math]::pow($A,2)   #create a new string $B and set it to$A raised to the power of 2
$A=$B.substring(0,4)           #set $A to the first 4 characters of$B
}

1