# Pairs with Sum divisible by 5

## Python 2, 32 bytes

lambda m,n:(m*n+abs(m%5-~n%5))/5


Try it online!

Adapts an idea from Arnauld. We estimate that $$\1/5\$$ of the $$\mn\$$ pairs will satisfy the mod-5 condition. Th actual value may be one higher depending on the mod-5 values of $$\m\$$ and $$\n\$$, and we bump up $$\mn\$$ a bit so that these make it pass the next multiple of 5.

34 bytes

lambda m,n:m*n/5+(0<-m%5*(-n%5)<5)


Try it online!

34 bytes

lambda m,n:m*n/5+(m*n%5+m%5+n%5)/9


Try it online!

36 bytes

lambda m,n:m*n/5+((5-m%5)*(5-n%5)<5)


Try it online!

36 bytes

lambda m,n:m*n/5+(abs(m%5+n%5*1j)>4)


Try it online!

36 bytes

lambda m,n:m*n/5+(m%5*5/4+n%5*5/4>5)


Try it online!

36 bytes

lambda m,n:m*n/5+(m%5+n%5+m*n%5/4>5)


Try it online!

## JavaScript (ES6), 29 bytes

Takes input as (m)(n).

m=>g=n=>n&&(m+n%5)/5+g(n-1)|0


Try it online!

### How?

Let's consider a grid of width $$\m\$$ with 1-indexed coordinates and an X mark on each cell for which:

$$(x+y)\equiv 0\pmod 5$$

Here are the first few rows for $$\m=9\$$:

   | 1 2 3 4 5 6 7 8 9
---+-------------------
1 | - - - X - - - - X
2 | - - X - - - - X -
3 | - X - - - - X - -
4 | X - - - - X - - -
5 | - - - - X - - - -
6 | - - - X - - - - X
7 | - - X - - - - X -


Computing $$\m+(y\bmod5)\$$ is equivalent to left-padding each row in such a way that all X marks are vertically aligned and appear on columns whose index is a multiple of $$\5\$$.

With such a configuration, the number of marks is directly given by $$\\lfloor{L_y/5}\rfloor\$$, where $$\L_y\$$ is the updated length of the $$\y\$$-th row.

 y | y%5 |         padded row         | length | // 5
---+-----+----------------------------+--------+------
1 |  1  |  + - - - X - - - - X       |   10   |   2
2 |  2  |  + + - - X - - - - X -     |   11   |   2
3 |  3  |  + + + - X - - - - X - -   |   12   |   2
4 |  4  |  + + + + X - - - - X - - - |   13   |   2
5 |  0  |  - - - - X - - - -         |    9   |   1
6 |  1  |  + - - - X - - - - X       |   10   |   2
7 |  2  |  + + - - X - - - - X -     |   11   |   2
---+-----+----------^---------^-------+--------+------
|  0 0 0 0 0 0 0 0 0 1 1 1 1 |
|  1 2 3 4 5 6 7 8 9 0 1 2 3 |

We use this method to recursively compute the number of marks on each row.

## Jelly, 5 bytes

p§5ḍS


Try it online!

### How?

p§5ḍS - Link: positive integer, M; positive integer N
p     - (implicit [1..M]) Cartesian product (implicit [1..N])
§    - sums
5ḍ  - five divides? (vectorises)
S - sum