Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
6 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Java 7, 39 38 bytes

int c(int a,int b){return~a*a*b*~b/4;}

Java 8, 26 25 19 18 17 bytes

a->b->a*~a*b*~b/4

Based on @xnor's excellent answer@xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Test code (Java 7):

Try it here.

class M{
  static int c(int a,int b){return~a*a*b*~b/4;}

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 38 bytes

int c(int a,int b){return~a*a*b*~b/4;}

Java 8, 26 25 19 18 17 bytes

a->b->a*~a*b*~b/4

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Test code (Java 7):

Try it here.

class M{
  static int c(int a,int b){return~a*a*b*~b/4;}

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 38 bytes

int c(int a,int b){return~a*a*b*~b/4;}

Java 8, 26 25 19 18 17 bytes

a->b->a*~a*b*~b/4

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Test code (Java 7):

Try it here.

class M{
  static int c(int a,int b){return~a*a*b*~b/4;}

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588
5 added 172 characters in body
source | link

Java 7, 3939 38 bytes

int c(int a,int b){return a*~a*b*~breturn~a*a*b*~b/4;}

Java 8, 26 25 19 1818 17 bytes

a->b->a*~a*b*~b/4;4

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Ungolfed & test casesTest code (Java 7):

Try it here.Try it here.

class MainM{
  static int c(int a, int b){
    return a * ~a * b * ~b return~a*a*b*~b/ 4;
  }

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 bytes

int c(int a,int b){return a*~a*b*~b/4;}

Java 8, 26 25 19 18 bytes

a->b->a*~a*b*~b/4;

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Ungolfed & test cases (Java 7):

Try it here.

class Main{
  static int c(int a, int b){
    return a * ~a * b * ~b / 4;
  }

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 38 bytes

int c(int a,int b){return~a*a*b*~b/4;}

Java 8, 26 25 19 18 17 bytes

a->b->a*~a*b*~b/4

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Test code (Java 7):

Try it here.

class M{
  static int c(int a,int b){return~a*a*b*~b/4;}

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588
4 -1 byte by changing (a,b)-> to a->b-> thanks to @DavidConrad
source | link

Java 7, 39 bytes

int c(int a,int b){return a*~a*b*~b/4;}

Java 8, 26 25 1719 18 bytes

(a,b)->b->a*~a*b*~b/4;

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Ungolfed & test cases (Java 7):

Try it here.

class Main{
  static int c(int a, int b){
    return a * ~a * b * ~b / 4;
  }

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 bytes

int c(int a,int b){return a*~a*b*~b/4;}

Java 8, 26 25 17 bytes

(a,b)->a*~a*b*~b/4;

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad.

Ungolfed & test cases (Java 7):

Try it here.

class Main{
  static int c(int a, int b){
    return a * ~a * b * ~b / 4;
  }

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588

Java 7, 39 bytes

int c(int a,int b){return a*~a*b*~b/4;}

Java 8, 26 25 19 18 bytes

a->b->a*~a*b*~b/4;

Based on @xnor's excellent answer. Multiple bytes saved thanks to @DavidConrad. Try it here.

Ungolfed & test cases (Java 7):

Try it here.

class Main{
  static int c(int a, int b){
    return a * ~a * b * ~b / 4;
  }

  public static void main(String[] a){
    System.out.println(c(0, 0));
    System.out.println(c(1, 1));
    System.out.println(c(3, 3));
    System.out.println(c(4, 4));
    System.out.println(c(6, 7));
  }
}

Output:

0
1
36
100
588
3 Bit late, but removed the return as suggested by @DavidConrad
source | link
2 Removed the trailing semi-colon from the Java 8 answer
source | link
1
source | link