OFFSET
0,5
LINKS
Fausto A. C. Cariboni, Table of n, a(n) for n = 0..80 (terms up to a(40) from Alois P. Heinz)
Wikipedia, Salem-Spencer set
FORMULA
a(n) = 2^n - A051013(n). - David Nacin, Mar 03 2012
EXAMPLE
For n=4 the only subsets containing an arithmetic progression of length 3 are {1,2,3}, {2,3,4} and {1,2,3,4}. Thus a(4) = 3. - David Nacin, Mar 03 2012
MATHEMATICA
a[n_] := a[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
from itertools import combinations as comb
def containsap3(n):
ap3list=list()
for skip in range(1, (n+1)//2):
for start in range (1, n+1-2*skip):
ap3list.append(set({start, start+skip, start+2*skip}))
s=list()
for i in range(3, n+1):
for temptuple in comb(range(1, n+1), i):
tempset=set(temptuple)
for sub in ap3list:
if sub <= tempset:
s.append(tempset)
break
return s #
# Counts all such sets
def a(n):
return len(containsap3(n)) # David Nacin, Mar 03 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
a(33) from Alois P. Heinz, Jan 31 2014
STATUS
approved