This code-golf challenge will give you two positive integers n
and k
as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectangle $$
\{(x,y) : 0 \leq x \leq n, 0 \leq y \leq k\}.
$$
That is, there should be:
- at least one vertex with an \$x\$-coordinate of \$0\$,
- at least one vertex with an \$x\$-coordinate of \$n\$,
- at least one vertex with an \$y\$-coordinate of \$0\$, and
- at least one vertex with an \$y\$-coordinate of \$k\$.
Example
There are \$a(5,7) = 5\$ rectangles with integer coordinates touching all four sides of a \$5 \times 7\$ rectangle:
Table
The lower triangle of the (symmetric) table of \$a(n,k)\$ for \$n,k \leq 12\$ is
n\k| 1 2 3 4 5 6 7 8 9 10 11 12
---+----------------------------------------------
1 | 1 . . . . . . . . . . .
2 | 1 2 . . . . . . . . . .
3 | 1 1 5 . . . . . . . . .
4 | 1 1 1 6 . . . . . . . .
5 | 1 1 1 3 9 . . . . . . .
6 | 1 1 1 1 1 10 . . . . . .
7 | 1 1 1 1 5 1 13 . . . . .
8 | 1 1 1 1 1 1 5 14 . . . .
9 | 1 1 1 1 1 5 1 1 17 . . .
10 | 1 1 1 1 1 3 1 3 1 18 . .
11 | 1 1 1 1 1 1 5 1 5 5 21 .
12 | 1 1 1 1 1 1 1 1 5 1 1 22
This is a code-golf challenge, so the shortest code wins.
n=k=5
: https://ibb.co/p49WdTc. Am I missing something? I also have larger results on other (bigger) test cases, here is my result for the table. \$\endgroup\$