[Question]
  [
> 
> Well, although this challenge turned out to be a huge success, it also turned out to be very trivial to solve. Therefore, for those of looking for more of a challenge, I created a sequel to this challenge in which you must now count the number of *unique* rectangles. [Check it out!](https://codegolf.stackexchange.com/q/87500/52405)
> 
> 
> Now, for those of you looking to solve *this* challenge, here it comes.
> 
> 
> 
---
Well, we don't really have a challenge like this yet, so here we go.
Consider this `3 x 3` grid of rectangles:
[![Example](https://i.stack.imgur.com/DoLX6.png)](https://i.stack.imgur.com/DoLX6.png)
How many rectangles are there? Well, counting visually, we can see that there are actually `36` rectangles, including the entire plane itself, which are all shown in the animated GIF below:
[![Rectangles in Example](https://i.stack.imgur.com/ItYuw.gif)](https://i.stack.imgur.com/ItYuw.gif)
## The Task
The counting of rectangles as shown above is the task. In other words, given 2 integers greater than or equal to `0`, `m` and `n`, where `m` represents the width and `n` represents the height, output the total number of rectangles in that `m x n` grid of rectangles.
## Rules
* The use of any built-ins that directly solve this problem is explicitly disallowed.
* This challenge is not about finding the shortest answer, but finding the shortest answer in every language. Therefore, no answer will be accepted.
* Standard loopholes are prohibited.
## Test Cases
Presented in the format `Array of Integers Input -> Integer Output`:
```
[0,0] -> 0
[1,1] -> 1
[3,3] -> 36 (Visualized above)
[4,4] -> 100
[6,7] -> 588
```
## References
* <http://oeis.org/A096948>
Remember, this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code wins!
  
[Answer]
## Python, 22 bytes
```
lambda m,n:m*~m*n*~n/4
```
The formula `m*n*(m+1)*(n+1)/4` is shortened using the bit-complement `~m=-(m+1)`, expressing `(m+1)*(n+1)` as `~m*~n`.
Why is the number of rectangles `m*n*(m+1)*(n+1)/4`? Each rectangle is specified by the choice of two horizontal lines (top and bottom) and two vertical lines (left and right). There are `m+1` horizontal lines, of which we choose a subset of two distinct ones. So the number of choices is `choose(m+1,2)`, which is `m*(m+1)/2`. Multiplying by the `n*(n+1)/2` choices for vertical lines gives the result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
RS€P
```
[Try it online!](http://jelly.tryitonline.net/#code=UlPigqxQ&input=&args=WzMsM10)
### Alternatively, also 4 bytes
```
pP€S
```
[Try it online!](http://jelly.tryitonline.net/#code=cFDigqxT&input=&args=Mw+Mw)
[Answer]
# Javascript (ES6), 17 bytes
```
m=>n=>m*n*~m*~n/4
```
A fork of [this answer](https://codegolf.stackexchange.com/a/87191/48934).
```
f=m=>n=>m*n*~m*~n/4
alert(f(prompt())(prompt()))
```
[Answer]
## Mathematica, 15 bytes
```
##(1##+##+1)/4&
```
This is an unnamed function taking two integer arguments and returning the number of rectangles.
### Explanation
The implementation is basically a very golfy form of the product of the two triangular numbers. It might be worth reading the section "Sequences of arguments" [in this post](https://codegolf.stackexchange.com/a/45188/8478) for the details, but I'll try to summarise the gist here.
`##` expands to a *sequence* of all arguments. This is similar to *splatting* in other languages. For instance, if the arguments are `3` and `4`, then `{1, 2, ##, 5}` will give you `{1, 2, 3, 4, 5}`. But this doesn't just work in lists, but in any expression whatsoever, e.g. `f[1, 2, ##, 5]` would also be `f[1, 2, 3, 4, 5]`.
This gets interesting when you combine `##` with operators. All operators in Mathematica are just short-hands for some `f[...]`-like expression (possibly nested). E.g. `a+b` is `Plus[a, b]` and `a-b` actually represents `Plus[a, Times[-1, b]]`. Now when you combine `##` with operators, what Mathematica does is to expand the operators first, treating `##` like a single operand, and expand them only at the end. By inserting `##` in the right places, we can therefore use it both to multiply and to add the operands.
Let's do this for the code above:
```
##(1##+##+1)/4
```
Expanding it to its full form, we get this:
```
Times[##, Plus[Times[1, ##], ##, 1], Rational[1/4]]
```
Let's insert the function arguments `a` and `b`:
```
Times[a, b, Plus[Times[1, a, b], a, b, 1], Rational[1/4]]
```
And now we convert it back into standard mathematical notation:
```
a * b * (a * b + a + b + 1) / 4
```
A little rearranging shows that this is the product of the triangular numbers:
```
a * b * (a + 1) * (b + 1) / 4
(a * (a + 1) / 2) * (b * (b + 1) / 2)
T(a) * T(b)
```
Fun fact: this implementation is so golfy, it's the same length as the built-in for computing a single triangular number, `PolygonalNumber`.
[Answer]
# C, 25 bytes
```
#define r(x,y)x*y*~x*~y/4
```
Purist version (27):
```
r(x,y){return x*y*~x*~y/4;}
```
ISO-er version (35):
```
#define r(x,y)((x)*(y)*~(x)*~(y)/4)
```
[Answer]
## [Jellyfish](https://github.com/iatorm/jellyfish/blob/master/doc.md), 16 bytes
```
p|%/**+1
  4  Ei
```
Input format is `[x y]`, output is just the result.
[Try it online!](http://jellyfish.tryitonline.net/#code=cHwlLyoqKzEKICA0ICBFaQ&input=WzYgN10)
Alternative solution, same byte count:
```
pm%/*[*i
  4  +1
```
### Explanation
Time to give Jellyfish the introduction it deserves! :)
Jellyfish is [Zgarb](https://codegolf.stackexchange.com/users/32014/zgarb)'s language [based on his 2D syntax challenge](https://codegolf.stackexchange.com/q/65661/8478). The semantics are largely inspired by J, but the syntax is a work of art. All functions are single characters and laid out on a grid. Functions take their arguments from the next token south and east of them and return the result north and west. This let's you create an interesting web of function calls where you reuse values by passing them into several functions from multiple directions.
If we ignore the fact that some of tokens in the above program are special *operators* (higher-level functions), the above program would be written something like this in a sane language:
```
p(|( /*(i*(i+1)) % 4 ))
```
Let's go through the code bottom-up. Input gets fed in by the `i`, which therefore evaluates to `[x y]`.
The `+` on top of it receives this input together with the literal `1` and therefore increments both elements to give `[(x+1) (y+1)]` (most operations are threaded automatically over lists).
The other value of `i` is sent left, but the `E` splits is eastern argument north and west. That means the inputs to the right `*` are actually `[x y]` and `[(x+1) (y+1)]` so this computes `[x*(x+1) y*(y+1)]`.
The next `*` up is actually modified by the preceding `/` which turns it into a fold operation. Folding `*` over a pair simply multiplies it, so that we get `x*(x+1)*y*(y+1)`.
Now `%` is just division so it computes `x*(x+1)*y*(y+1)/4`. Unfortunately, this results in a float so we need to round it with the unary `|`. Finally, this value is fed to `p` which prints the final result.
[Answer]
# R, ~~40~~ 35 bytes
Well, time to jump in at the deep end ! Here is my **R** code, inspired from @xnor answer : 
```
a=scan();(n=a[1])*(m=a[2])*(n+1)*(m+1)/4 
```
*EDIT* : In this version, **R** will ask twice for inputs.
```
(n=scan())*(m=scan())*(n+1)*(m+1)/4
```
[Answer]
# CJam, ~~12~~ 10 Bytes
2 bytes saved thanks to Martin.
```
{_:)+:*4/}
```
[Try it online!](http://cjam.tryitonline.net/#code=cmlhcmkre186KSs6KjQvfX4&input=MyAz)
This is a block that takes a list of 2 elements from the stack and leaves the solution on the stack. Usable full program for testing: `riari+{_:)+:*4/}~`.
Based off of xnor's outstanding python solution.
Explanation:
```
{_:)+:*4/}
{        } -- Define a block
 _:)       -- Duplicate list, increment all values in new list
    +      -- Join the two lists
     :*    -- Fold multiply over all 4 elements
       4/  -- Divide by 4
```
[Answer]
## Matlab, ~~23~~ 19 bytes
```
@(x)prod([x/2,x+1])
```
Implementation of the formula `m*n*(m+1)*(n+1)/4`  
Usage: `ans([m,n])`
[Answer]
# [MATL](https://github.com/lmendo/MATL), 6 bytes
```
tQ*2/p
```
Input is an array of the form `[m,n]`.
[**Try it online!**](http://matl.tryitonline.net/#code=dFEqMi9w&input=WzYsN10)
### Explanation
Direct computation based on the formula `m*(m+1)*n*(n+1)/4`.
```
t     % Input array [m,n] implicitly. Duplicate
Q     % Add 1 to each entry of the copy: gives [m+1,n+1]
*     % Multiply element-wise: gives [m*(m+1),n*(n+1)]
2/    % Divide each entry by 2: [m*(m+1)/2,n*(n+1)/2]
p     % Product of the two entries: m*(m+1)*n*(n+1)/4. Display implicitly
```
[Answer]
# J, 8 bytes
```
2*/@:!>:
```
**Usage:**
```
   f =: 2*/@:!>:
   f 0 0
0
   f 3 3
36
```
[Answer]
# 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](https://codegolf.stackexchange.com/a/87191/52210). Multiple bytes saved thanks to *@DavidConrad*. [Try it here.](https://ideone.com/lraSKq)
**Test code (Java 7):**
[Try it here.](https://tio.run/nexus/java-openjdk#fcyxCoMwGATg3ae4MZFgFaUdfAYnx9LhTyoloFHMb6GIvrptaNdmueW@O9OT92jWBPBMbM1hHcOIkKRCarnOHS@z2ymlVKe7PlX1dgDTontrfjM8R3vHQNaJlmfrHtcbSIZboH157oZsXDibPhX3ThiRK@RS1v9BoVBEQalQRkGlUEXBWeHyBVuyHW8)
```
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
```
[Answer]
# Ruby, 22 bytes
Stealing @xnor's trick and making a stabby-lambda:
```
r=->(m,n){m*n*~m*~n/4}
```
Example call:
```
r[6,7]     # => 588
```
Or as a proc, also 22 bytes:
```
proc{|m,n|m*n*~m*~n/4}
```
Which we could then call:
```
proc{|m,n|m*n*~m*~n/4}.call(6,7)     # => 588
```
[Answer]
## [Labyrinth](https://github.com/m-ender/labyrinth), ~~13~~ 11 bytes
```
*?;*_4/!
):
```
[Try it online!](http://labyrinth.tryitonline.net/#code=Kj87Kl80LyEKKTo&input=NiA3)
### Explanation
This also computes the product of the triangular numbers like most answers. The leading 2x2 block is a small loop:
```
*?
):
```
On the first iteration `*` doesn't do anything, so that the real loop order is this:
```
?   Read integer N from STDIN or 0 at EOF and push onto stack. If 0, exit the loop.
:   Duplicate N.
)   Increment.
*   Multiply to get N*(N+1).
```
The remaining code is just linear:
```
;   Discard the zero that terminated the loop.
*   Multiply the other two values.
_4  Push a 4.
/   Divide.
!   Print.
```
Labyrinth then tries to execute `/` again, which terminates the program due to a division by zero.
[Answer]
## Pyke, 6 bytes
```
mh+Bee
```
[Try it here!](http://pyke.catbus.co.uk/?code=mh%2BBee&input=%5B3%2C3%5D)
```
mh     -    map(increment, input)
  +    -   ^ + input
   B   -  product(^)
    ee - ^ \ 4
```
[Answer]
## 05AB1E, 4 bytes
```
€LOP
```
**Explanation**
Uses the formula described at [A096948](http://oeis.org/A096948)
```
      # Implicit input, ex: [7,6]
€L    # Enumerate each, [[1,2,3,4,5,6,7],[1,2,3,4,5,6]]
  O   # Sum, [28,21]
   P  # Product, 588
      # Implicit display
```
Takes input as **[n,m]**.
[Try it online](http://05ab1e.tryitonline.net/#code=4oKsTE9Q&input=WzcsNl0)
[Answer]
# Pyth, ~~8~~ 6 bytes
Two bytes saved thanks to @DenkerAffe.
```
*FmsSd
```
Input is expected as a list like `[m,n]`. Try it out [here](https://pyth.herokuapp.com/?code=%2aFmsSd&input=%5B6%2C7%5D&test_suite=1&test_suite_input=%5B0%2C0%5D%0A%5B1%2C1%5D%0A%5B3%2C3%5D%0A%5B4%2C4%5D%0A%5B6%2C7%5D&debug=0).
Explanation:
```
          Implicit assignment of Q to eval(input).
*         Multiplication.
 F        Splat the following sequence onto the arguments of the previous function.
  m       Map the following function of d over Q (Q is implicitly added to the end).
   s      Reduce the following list with addition, initial value of 0.
    Sd    Return range(1,d+1).
```
[Answer]
## C#, 19 bytes
```
(n,m)=>m*n*~m*~n/4;
```
An anonymous function based off of @xnor's answer.
[Answer]
## Lua, ~~74~~ 63 bytes
```
x,y=...n=0 for i=1,y do for j=i,i*x,i do n=n+j end end print(n)
```
Function takes input as number parameters.
Because of the way Lua is implemented, this is technically a function, with variable args, which can be called by wrapping it in a "function" statement, or loading it from source code using "loadstring"
[Answer]
# [Cheddar](https://github.com/cheddar-lang/Cheddar), 23 bytes
```
m->n->m*(m+1)*n*(n+1)/4
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~84~~ 80 bytes
```
({}<>)({({})<({}[()])>}{})<>({({})<({}[()])>}{}[()]){<>(({}))<>({}[()])}<>({{}})
```
[Try it online!](https://tio.run/nexus/brain-flak#@69RXWtjp6lRDaQ1bYBEtIZmrKZdLYhnh0UUzKgGSoFkwEogQrUgZnVtreb//2YK5gA "Brain-Flak – TIO Nexus")
Probably very sub-optimal, especially because of the code reuse regarding triangle numbers, but at least we have a Brain-Flak solution that works.
Sadly it seems to fail by looping infinitely with the `0 0` testcase but all others work fine.
[Answer]
## Convex, 7 bytes
I know that this can be smaller, I just can't figure out how yet...
```
_:)+×½½
```
[Try it online!](http://convex.tryitonline.net/#code=XzopK8OXwr3CvQ&input=&args=WzMgM10). Uses the CP-1252 encoding.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 9 bytes
```
×/+/∘⍳¨∘⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TD0/W19R91zHjUu/nQChDdtQgooWCgYMCVpmCoYAgkjRWMgaSJggmQNFMwBwA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 3 [bytes](https://github.com/mudkip201/pyt/wiki/Codepage)
```
←△Π
```
Explanation:
```
←       Get input
 △      Get triangle numbers
  Π     Array product
        Implicit output
```
[Try it online!](https://tio.run/##K6gs@f//UduER9M2n1vw/3@0qY5lLAA)
]