OFFSET
1,2
COMMENTS
a(1)=1, a(2)=7; a(n) is least k such that no three terms of a(1), a(2), ..., a(n-1), k form an arithmetic progression.
LINKS
FORMULA
a(n) = (Sum_{k=1..n-1} (3^A007814(k) + 1)/2) + f(n), with f(n) an 8-periodic function with values {1, 6, 5, 6, 2, 6, 5, 7, ...}, as proved by Lawrence Sze.
MAPLE
N:= 1000: # to get all terms <= N
V:= Vector(N, 1):
A[1]:= 1: A[2]:= 7: k:= 8;
for n from 3 while k < N do
for k from 1 to n-2 do
p:= 2*A[n-1]-A[k];
if p <= N then V[p]:= 0 fi
od:
for k from A[n-1]+1 to N do
if V[k] = 1 then A[n]:= k; nmax:= n; break fi;
od;
od:
seq(A[i], i=1..nmax); # Robert Israel, May 07 2018
MATHEMATICA
a[n_] := Sum[(1/2)(3^IntegerExponent[k, 2]+1), {k, 1, n-1}] + (1/8)( 12(-1)^n - 7Sin[n Pi/2] + 7Sin[3n Pi/2] - Sin[(n+1)Pi/4] + Sin[(5n+1) Pi/4] + Cos[n Pi/2] + Cos[3n Pi/2] + Cos[n Pi/4] + Cos[3n Pi/4] + Cos[5n Pi/4] + Cos[7n Pi/4] + Cos[(3n+1)Pi/4] - Cos[(7n+1)Pi/4] + 38); Array[a, 60] (* Jean-François Alcover, Mar 22 2019 *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Ralf Stephan, Apr 09 2004
STATUS
approved