Skip to main content
added 49 characters in body
Source Link
JAD
  • 3k
  • 1
  • 11
  • 31

R, 58 56 5555 53 bytes

x=3333.4;forx=3334;for(e in N<-scan():1)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 3334 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

Saved 2 bytes thanks to @ETHproductions

R, 58 56 55 bytes

x=3333.4;for(e in N<-scan():1)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

R, 58 56 55 53 bytes

x=3334;for(e in N<-scan():1)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3334 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

Saved 2 bytes thanks to @ETHproductions

added 9 characters in body
Source Link
JAD
  • 3k
  • 1
  • 11
  • 31

R, 58 5656 55 bytes

N=scan();x=3333x=3333.4;for(e in 1N<-scan():N1)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

R, 58 56 bytes

N=scan();x=3333.4;for(e in 1:N)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

R, 58 56 55 bytes

x=3333.4;for(e in N<-scan():1)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.

Source Link
JAD
  • 3k
  • 1
  • 11
  • 31

R, 58 56 bytes

N=scan();x=3333.4;for(e in 1:N)x=x^2%/%10^(3+(x>3162));x

Takes N from stdin. 3333.4 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).

R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163 and x>3162, the former yield a 6 digit number, the latter a 7 digit number.

The rest is pretty straightforward, %/% divides and ignores the remainder. x is printed to stdout.