OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..13
Wikipedia, Pairing function
FORMULA
a(n) = c({1}^n) with c() = 0, c(n) = n, c(n,k) = (n+k)*(n+k+1)/2+k, c(n_1,...,n_{k-1},n_k) = c(c(n_1,...,n_{k-1}),n_k) for k>2.
a(n) = (a(n-1)+1)*(a(n-1)+2)/2+1 for n>1, a(n) = n for n<=1.
EXAMPLE
a(2) = c(1,1) = 2*3/2+1 = 4.
a(3) = c(1,1,1) = c(c(1,1),1) = c(4,1) = 5*6/2+1 = 16.
MAPLE
a:= proc(n) a(n):= `if`(n<2, n, (g-> g*(g+1)/2)(a(n-1)+1)+1) end:
seq(a(n), n=0..10);
MATHEMATICA
a[n_] := a[n] = If[n<2, n, Function[g, g*(g+1)/2][a[n-1]+1]+1];
Table[a[n], {n, 0, 10}] (* Jean-François Alcover, Jun 01 2018, from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jun 12 2013
STATUS
approved