OFFSET
0,2
LINKS
Fausto A. C. Cariboni, Table of n, a(n) for n = 0..80
Eric Weisstein's World of Mathematics, Nonaveraging Sequence
Wikipedia, Salem-Spencer set
FORMULA
a(n) = 2^n - A018788(n). - David Nacin, Mar 03 2012
EXAMPLE
The only subset of s = {1,2,3} that contains a 3-term arithmetic progression is s itself, so a(3) = 7.
MATHEMATICA
a[n_] := a[n] = 2^n - Count[Subsets[Range[n], {3, n}], {___, a_, ___, b_, ___, c_, ___} /; b-a == c-b]; Table[Print[n, " ", a[n]]; a[n], {n, 0, 32}] (* Jean-François Alcover, May 30 2019 *)
PROG
(Python)
# Prints out all such sets
def nonaveragingsets(n):
avoid=list()
for skip in range(1, (n+1)//2):
for start in range (1, n+1-2*skip):
avoid.append(set({start, start+skip, start+2*skip}))
s=list()
for i in range(3):
for smallset in comb(range(1, n+1), i):
s.append(smallset)
for i in range(3, n+1):
for temptuple in comb(range(1, n+1), i):
tempset=set(temptuple)
status=True
for avoidset in avoid:
if avoidset <= tempset:
status=False
break
if status:
s.append(tempset)
return s
# Counts all such sets
def a(n):
return len(nonaveragingsets(n)) # David Nacin, Mar 03 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
More terms from John W. Layman, Nov 27 2001
a(29)-a(37) from Donovan Johnson, Aug 15 2010
a(38)-a(40) from Alois P. Heinz, Oct 27 2011
STATUS
approved