OFFSET
0,2
LINKS
Justin Gaetano, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (1,3,-3,-3,3,1,-1)
FORMULA
a(n) = (3*n/2)^2*(3*n/2+1)/2 if n even.
a(n) = ((3*n+1)/2)^2*((3*n+1)/2+1)/2 if n odd.
From Omar E. Pol, Feb 21 2018: (Start)
G.f.: 3*x*(3*x^4 + 5*x^3 + 13*x^2 + 4*x + 2)/((x-1)^4*(x+1)^3). - Robert Israel, Feb 28 2018
EXAMPLE
The first 6 pentagonal pyramidal numbers are 0, 1, 6, 18, 40, 75; of these, 0, 6, 18, 75 are divisible by 3.
MAPLE
f:= proc(n) if n::even then (3*n/2)^2*(3*n/2+1)/2 else
((3*n+1)/2)^2*((3*n+1)/2+1)/2 fi end proc:
map(f, [$0..100]); # Robert Israel, Feb 28 2018
MATHEMATICA
Array[((3 #1 + #2)/2)^2*((3 #1 + #2)/2 + 1)/2 & @@ {#, Boole@ OddQ@ #} &, 47, 0] (* Michael De Vlieger, Feb 21 2018 *)
LinearRecurrence[{1, 3, -3, -3, 3, 1, -1}, {0, 6, 18, 75, 126, 288, 405}, 50] (* Harvey P. Dale, Jul 16 2021 *)
PROG
(PARI) lista(nn) = {for (n=0, nn, if (!(n^2*(n+1)/2 % 3), print1(n^2*(n+1)/2, ", ")); ); } \\ Michel Marcus, Feb 21 2018
(PARI) x='x+O('x^99); concat(0, Vec(3*x*(3*x^4+5*x^3+13*x^2+4*x+2)/((x-1)^4*(x+1)^3))) \\ Altug Alkan, Mar 14 2018
(Magma) [IsEven(n) select (3*n/2)^2*(3*n/2+1)/2 else ((3*n+1)/2)^2*((3*n+1)/2+1)/2: n in [0..50] ]; // Vincenzo Librandi, Mar 14 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Justin Gaetano, Feb 20 2018
STATUS
approved