OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
F. Iacobescu, Smarandache Partition Type and Other Sequences, Bull. Pure Appl. Sci. 16E, 237-240, 1997.
Eric Weisstein's World of Mathematics, Nonarithmetic Progression Sequence
FORMULA
a(n) = (3-n)/2 + 2*floor(n/2) + Sum_{k=1..n-1} 3^A007814(k)/2 = A003278(n) + [n is even], proved by Lawrence Sze, following a conjecture by Ralf Stephan.
a(n) = b(n-1), with b(0)=1, b(2n) = 3b(n) - 2 - 3[n odd], b(2n+1) = 3b(n)-3[n odd].
MAPLE
a:= proc(n) local m, r, b; m, r, b:= n-1, 2-irem(n, 2), 1;
while m>0 do r:= r+b*irem(m, 2, 'm'); b:= b*3 od; r
end:
seq(a(n), n=1..100); # Alois P. Heinz, Nov 02 2021
MATHEMATICA
Select[Range[1000], MatchQ[IntegerDigits[#-1, 3], {(0|1)..., 0|2}]&] (* Jean-François Alcover, Jan 13 2019, after Tanya Khovanova in A186776 *)
PROG
(PARI) v[1]=1; v[2]=3; for(n=3, 1000, f=2; m=v[n-1]+1; while(1, forstep(k=n-1, 1, -1, if(v[k]<(m+1)/2, f=1; break); for(l=1, k-1, if(m-v[k]==v[k]-v[l], f=0; break)); if(f<2, break)); if(!f, m=m+1; f=2); if(f==1, break)); v[n]=m) \\ Ralf Stephan
(PARI) a(n)=if(n<1, 1, if(n%2==0, 3*a(n/2)-2-3*((n/2)%2), 3*a((n-1)/2)-3*(((n-1)/2)%2))) \\ Ralf Stephan
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Rechecked by David W. Wilson, Jun 04 2002
STATUS
approved