OFFSET
0,2
LINKS
Seiichi Manyama, Table of n, a(n) for n = 0..404
FORMULA
a(n) ~ sqrt(Pi) * 2^(n - 1/2) * n^(n - 1/2) / exp(n-1). - Vaclav Kotesovec, Apr 06 2019
a(n) = 2*(n-1)*a(n-1) + a(n-2) - 2*(n-2), with a(0) = 1, a(1) = 2. - G. C. Greubel, Oct 09 2023
MATHEMATICA
a[n_]:= a[n]= If[n<2, n+1, 2*(n-1)*a[n-1] +a[n-2] -2*(n-2)];
Table[a[n], {n, 0, 30}] (* G. C. Greubel, Oct 09 2023 *)
PROG
(Ruby)
def A144503(n)
ary = []
a = [1]
(n + 1).times{|i|
(1..i).each{|j|
a[j] *= i - j
a[j] += a[j - 1]
}
ary << a.inject(:+)
a << 0
}
ary
end
p A144503(20) # Seiichi Manyama, Apr 06 2019
(Magma) [n le 2 select n else 2*(n-2)*Self(n-1) +Self(n-2) -2*(n-3): n in [1..30]]; // G. C. Greubel, Oct 09 2023
(SageMath)
@CachedFunction
def a(n): # A144503
if (n<2): return n+1
else: return 2*(n-1)*a(n-1) + a(n-2) - 2*(n-2)
[a(n) for n in range(31)] # G. C. Greubel, Oct 09 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
David Applegate and N. J. A. Sloane, Dec 13 2008
STATUS
approved