We’re rewarding the question askers & reputations are being recalculated! Read more.
9 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) ClojureClojure and MatlabMatlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

8 replaced http://meta.stackexchange.com/ with https://meta.stackexchange.com/
source | link

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

ThanksThanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

7 added 62 characters in body
source | link

Java 8, 77 93 74 71 6969 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));;return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

Java 8, 77 93 74 71 69 78 bytes

int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4));}

x->{int n=1111;int m=1;while(x>m++){n=Integer.parseInt((n*n+"").substring(0,4))‌​;}return n;}

x->{int n=1111;for(;--x>0;){n=Integer.parseInt((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;){n=Long.valueOf((n*n+"").substring(0,4));}}

x->{long n=1111;for(;--x>0;)n=Long.valueOf((n*n+"").substring(0,4));return n;}

Each repetition makes n the first 4 characters of n*n.

Try Java online!

Post history:

  • 77 bytes: initial code (incomplete)

  • +16 bytes, by Olivier Grégoire: completed code by making it a Lambda function.

  • -19 bytes: replace while with for cycle.

  • -4 bytes: used longs instead of ints

  • -2 bytes, by Roman Gräf: removed unnecessary brackets

  • +9 bytes, missing return statement

Thanks to @OlivierGrégoire and @RomanGräf for pointing out some issues!

Wait, Java beats... (drumroll) Clojure and Matlab here! A big applause to Java please!

6 added 136 characters in body
source | link
5 added info
source | link
4 added history
source | link
3 added 90 characters in body
source | link
2 added 126 characters in body
source | link
1
source | link