proposed
approved
editing
proposed
(PARI) slista(nn) = { nn = max(nn, 3); my(va = vector(nn)); va[1] = 1; va[2] = 3; va[3] = 1; my(sa = vecsum(va)); for (n) = {if4, nn, va[n] = sa + va[2*(n< - 1, 0 - 2^logint(n-2, 2))]; sa += va[n]; ); va; } \\ _Petros Hadjicostas_, May 03 2020
if(s_table == 's_table, s_table = [1]);
if(#s_table < n, s_table=concat(s_table, vector(n-#s_table)));
if(s_table[n], s_table[n], s_table[n] = s(n-1)+a(n))}
m(n)={if(n<2, 0, -2^ceil(log(n-1)/log(2)) + 2*n - 2)}
a(n)={if(n<=3, return(2+(-1)^n));
if(a_table == 'a_table, a_table = [1]);
if(#a_table < n, a_table=concat(a_table, vector(n-#a_table)));
if(a_table[n], a_table[n], a_table[n] = s(n-1) + a(m(n)))}
for(n=1, 40, print1(a(n), ", ")); \\ Petros Hadjicostas, Apr 24 2020
approved
editing
reviewed
approved
proposed
reviewed
editing
proposed
a(n)={if(n<=3, return(2^+(n-1)^n));
m(n)={if(n<2, 0, -2^ceil(-1+log(n-1)/log(2)) + 2*n - 12)}