OFFSET
1,4
COMMENTS
a(n-1) and a(n) are the lesser and greater of a twin prime pair if and only if a(n) = a(n-1) + 2 where a(n-1) and a(n) are prime.
FORMULA
a(n) = (1+(-1)^n)*(1+floor(sqrt(2*n-1-(-1)^n)))/2-((2*n+1-(-1)^n)/2-2 *Sum_{k=1..floor(sqrt(2*n-2-(-1)^n)-1)} floor((k+1)/2))*(-1)^n/2.
EXAMPLE
[1,9]
[1,7] [1,8] [2,8]
[1,5] [1,6] [2,6] [2,7] [3,7]
[1,3] [1,4] [2,4] [2,5] [3,5] [3,6] [4,6]
[1,1] [1,2] [2,2] [2,3] [3,3] [3,4] [4,4] [4,5] [5,5]
k 2 3 4 5 6 7 8 9 10
--------------------------------------------------------------------------
k Nondecreasing partitions of k
--------------------------------------------------------------------------
2 1,1
3 1,2
4 1,3,2,2
5 1,4,2,3
6 1,5,2,4,3,3
7 1,6,2,5,3,4
8 1,7,2,6,3,5,4,4
9 1,8,2,7,3,6,4,5
10 1,9,2,8,3,7,4,6,5,5
...
MATHEMATICA
t[n_] := Flatten[Reverse /@ IntegerPartitions[n, {2}]]; Array[t, 14, 2] // Flatten (* Amiram Eldar, Dec 03 2020 *)
Table[(1 + (-1)^n) (1 + Floor[Sqrt[2 n - 1 - (-1)^n]])/2 - ((2 n + 1 - (-1)^n)/2 - 2 Sum[Floor[(k + 1)/2], {k, -1 + Floor[Sqrt[2 n - 2 - (-1)^n]]}]) (-1)^n/2, {n, 100}] (* Wesley Ivan Hurt, Dec 04 2020 *)
PROG
(PARI) row(n) = vector(n\2, i, [i, n-i]);
tabf(nn) = for (n=2, nn, print(row(n))); \\ Michel Marcus, Dec 03 2020
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
Wesley Ivan Hurt, Dec 02 2020
STATUS
approved