OFFSET
1,2
LINKS
Wikipedia, Lissajous curve
FORMULA
T(n,k) = (n-1)*(k-1) + n*k when n is odd and GCD(n,k) = 1.
T(n,k) = (n-1)*(k-1)/2 when n is even and GCD(n,k) = 1.
T(n,k) = T(n/m,k/m) when GCD(n,k) = m.
EXAMPLE
Array begins:
+-----+---------------------------------------------------------------+
| n\k | 1 2 3 4 5 6 7 8 9 10 11 12 .. |
+-----+---------------------------------------------------------------+
| 1 | 1 2 3 4 5 6 7 8 9 10 11 12 .. |
| 2 | 0 1 1 2 2 3 3 4 4 5 5 6 .. |
| 3 | 3 8 1 18 23 2 33 38 3 48 53 4 .. |
| 4 | 0 0 3 1 6 1 9 2 12 2 15 3 .. |
| 5 | 5 14 23 32 1 50 59 68 77 2 95 104 .. |
| 6 | 0 3 0 8 10 1 15 18 1 23 25 2 .. |
| 7 | 7 20 33 46 59 72 1 98 111 124 137 150 .. |
| 8 | 0 0 7 0 14 3 21 1 28 6 35 1 .. |
| 9 | 9 26 3 60 77 8 111 128 1 162 179 18 .. |
| 10 | 0 5 9 14 0 23 27 32 36 1 45 50 .. |
| 11 | 11 32 53 74 95 116 137 158 179 200 1 242 .. |
| 12 | 0 0 0 3 22 0 33 8 3 10 55 1 .. |
| .. | .. .. .. .. .. .. .. .. .. .. .. .. .. |
+---------------------------------------------------------------------+
MAPLE
T := proc(n, k) option remember; igcd(n, k); if % = 1 then (n-1)*(k-1);
ifelse(n::even, % / 2, % + n*k) else T(n / %, k / %) fi end:
seq(seq(T(k, n - k + 1), k = 1..n), n = 1..12); # Peter Luschny, Oct 31 2021
MATHEMATICA
T[n_, k_] := T[n, k] = With[{m = GCD[n, k]}, Which[OddQ[n] && m == 1, (n-1)*(k-1)+n*k, EvenQ[n] && m == 1, (n-1)*(k-1)/2, True, T[n/m, k/m]]];
Table[Table[T[k, n - k + 1], {k, 1, n}], {n, 1, 12}] // Flatten (* Jean-François Alcover, Oct 28 2023 *)
CROSSREFS
KEYWORD
AUTHOR
Mohammed Yaseen, Oct 31 2021
STATUS
approved