Skip to main content
Commonmark migration
Source Link

#Java 7, 125 bytes

Java 7, 125 bytes

void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

Ungolfed:

void c() {
  long x = System.nanoTime(),
       i = -1001;
  for(; i < 1e3; ){
    System.out.println(++i);
  }
  System.out.println((System.nanoTime() - x) / i / i);
}

Test code:

Try it here.

class M{
  static void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

  public static void main(String[] a){
    c();
  }
}

Example output:

-1000
-999
...
...
...
999
1000
13

#Java 7, 125 bytes

void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

Ungolfed:

void c() {
  long x = System.nanoTime(),
       i = -1001;
  for(; i < 1e3; ){
    System.out.println(++i);
  }
  System.out.println((System.nanoTime() - x) / i / i);
}

Test code:

Try it here.

class M{
  static void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

  public static void main(String[] a){
    c();
  }
}

Example output:

-1000
-999
...
...
...
999
1000
13

Java 7, 125 bytes

void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

Ungolfed:

void c() {
  long x = System.nanoTime(),
       i = -1001;
  for(; i < 1e3; ){
    System.out.println(++i);
  }
  System.out.println((System.nanoTime() - x) / i / i);
}

Test code:

Try it here.

class M{
  static void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

  public static void main(String[] a){
    c();
  }
}

Example output:

-1000
-999
...
...
...
999
1000
13
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 7, 125 bytes

void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

Ungolfed:

void c() {
  long x = System.nanoTime(),
       i = -1001;
  for(; i < 1e3; ){
    System.out.println(++i);
  }
  System.out.println((System.nanoTime() - x) / i / i);
}

Test code:

Try it here.

class M{
  static void c(){long x=System.nanoTime(),i=-1001;for(;i<1e3;)System.out.println(++i);System.out.println((System.nanoTime()-x)/i/i);}

  public static void main(String[] a){
    c();
  }
}

Example output:

-1000
-999
...
...
...
999
1000
13