A083317 Erroneous version of A005047.
3, 4, 8, 10, 12, 13, 19, 24, 25
Offset: 3
Keywords
References
- R. K. Guy, Unsolved Problems in Number Theory, E10.
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
import Data.IntMap (empty, (!), insert) a229037 n = a229037_list !! (n-1) a229037_list = f 0 empty where f i m = y : f (i + 1) (insert (i + 1) y m) where y = head [z | z <- [1..], all (\k -> z + m ! (i - k) /= 2 * m ! (i - k `div` 2)) [1, 3 .. i - 1]] -- Reinhard Zumkeller, Apr 26 2014
a[1] = 1; a[n_] := a[n] = Block[{z = 1}, While[Catch[ Do[If[z == 2*a[n-k] - a[n-2*k], Throw@True], {k, Floor[(n-1)/2]}]; False], z++]; z]; a /@ Range[100] (* Giovanni Resta, Jan 01 2014 *)
step(v)=my(bad=List(),n=#v+1,t); for(d=1,#v\2,t=2*v[n-d]-v[n-2*d]; if(t>0, listput(bad,t))); bad=Set(bad); for(i=1,#bad, if(bad[i]!=i, return(i))); #bad+1 first(n)=my(v=List([1])); while(n--, listput(v, step(v))); Vec(v) \\ Charles R Greathouse IV, Jan 21 2014
A229037_list = [] for n in range(10**6): i, j, b = 1, 1, set() while n-2*i >= 0: b.add(2*A229037_list[n-i]-A229037_list[n-2*i]) i += 1 while j in b: b.remove(j) j += 1 A229037_list.append(j) # Chai Wah Wu, Dec 21 2014
Examples from Dybizbanski (2012) (includes earlier examples found by other people): n, a(n), example of an optimal subset: 0, 0, [] 1, 1, [1] 2, 2, [1, 2] 4, 3, [1, 2, 4] 5, 4, [1, 2, 4, 5] 9, 5, [1, 2, 4, 8, 9] 11, 6, [1, 2, 4, 5, 10, 11] 13, 7, [1, 2, 4, 5, 10, 11, 13] 14, 8, [1, 2, 4, 5, 10, 11, 13, 14] 20, 9, [1, 2, 6, 7, 9, 14, 15, 18, 20] 24, 10, [1, 2, 5, 7, 11, 16, 18, 19, 23, 24] 26, 11, [1, 2, 5, 7, 11, 16, 18, 19, 23, 24, 26] 30, 12, [1, 3, 4, 8, 9, 11, 20, 22, 23, 27, 28, 30] 32, 13, [1, 2, 4, 8, 9, 11, 19, 22, 23, 26, 28, 31, 32] 36, 14, [1, 2, 4, 8, 9, 13, 21, 23, 26, 27, 30, 32, 35, 36] 40, 15, [1, 2, 4, 5, 10, 11, 13, 14, 28, 29, 31, 32, 37, 38, 40] 41, 16, [1, 2, 4, 5, 10, 11, 13, 14, 28, 29, 31, 32, 37, 38, 40, 41] 51, 17, [1, 2, 4, 5, 10, 13, 14, 17, 31, 35, 37, 38, 40, 46, 47, 50, 51] 54, 18, [1, 2, 5, 6, 12, 14, 15, 17, 21, 31, 38, 39, 42, 43, 49, 51, 52, 54] 58, 19, [1, 2, 5, 6, 12, 14, 15, 17, 21, 31, 38, 39, 42, 43, 49, 51, 52, 54, 58] 63, 20, [1, 2, 5, 7, 11, 16, 18, 19, 24, 26, 38, 39, 42, 44, 48, 53, 55, 56, 61, 63] 71, 21, [1, 2, 5, 7, 10, 17, 20, 22, 26, 31, 41, 46, 48, 49, 53, 54, 63, 64, 68, 69, 71] 74, 22, [1, 2, 7, 9, 10, 14, 20, 22, 23, 25, 29, 46, 50, 52, 53, 55, 61, 65, 66, 68, 73, 74] 82, 23, [1, 2, 4, 8, 9, 11, 19, 22, 23, 26, 28, 31, 49, 57, 59, 62, 63, 66, 68, 71, 78, 81, 82]
(* Program not suitable to compute a large number of terms *) a[n_] := a[n] = For[r = Range[n]; k = n, k >= 1, k--, If[AnyTrue[Subsets[r, {k}], FreeQ[#, {_, a_, _, b_, _, c_, _} /; b - a == c - b] &], Return[k]]]; Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 1, 25}] (* Jean-François Alcover, Jan 21 2018 *)
ap3(v)=for(i=1,#v-2, for(j=i+2,#v, my(t=v[i]+v[j]); if(t%2==0 && setsearch(v,t/2), return(1)))); 0 a(N)=forstep(n=N,2,-1, forvec(v=vector(n,i,[1,N]),if(!ap3(v), return(n)),2)); N \\ Charles R Greathouse IV, Apr 22 2022
a(9) = 20 = 1 2 6 7 9 14 15 18 20 a(10) = 24 = 1 2 5 7 11 16 18 19 23 24 a(11) = 26 = 1 2 5 7 11 16 18 19 23 24 26 a(12) = 30 = 1 3 4 8 9 11 20 22 23 27 28 30 (unique) a(13) = 32 = 1 2 4 8 9 11 19 22 23 26 28 31 32 a(14) = 36 = 1 2 4 8 9 13 21 23 26 27 30 32 35 36 a(15) = 40 = 1 2 4 5 10 11 13 14 28 29 31 32 37 38 40 a(16) = 41 = 1 2 4 5 10 11 13 14 28 29 31 32 37 38 40 41 a(17) = 51 = 1 2 4 5 10 13 14 17 31 35 37 38 40 46 47 50 51 a(18) = 54 = 1 2 5 6 12 14 15 17 21 31 38 39 42 43 49 51 52 54 a(19) = 58 = 1 2 5 6 12 14 15 17 21 31 38 39 42 43 49 51 52 54 58 a(20) = 63 = 1 2 5 7 11 16 18 19 24 26 38 39 42 44 48 53 55 56 61 63 a(21) = 71 = 1 2 5 7 10 17 20 22 26 31 41 46 48 49 53 54 63 64 68 69 71 a(22) = 74 = 1 2 7 9 10 14 20 22 23 25 29 46 50 52 53 55 61 65 66 68 73 74 a(23) = 82 = 1 2 4 8 9 11 19 22 23 26 28 31 49 57 59 62 63 66 68 71 78 81 82 a(24) = 84 = 1 3 4 8 9 16 18 21 22 25 30 37 48 55 60 63 64 67 69 76 77 81 82 84 a(25) = 92 = 1 2 6 8 9 13 19 21 22 27 28 39 58 62 64 67 68 71 73 81 83 86 87 90 92 a(26) = 95 = 1 2 4 5 10 11 22 23 25 26 31 32 55 56 64 65 67 68 76 77 82 83 91 92 94 95 a(27) = 100 = 1 3 6 7 10 12 20 22 25 26 29 31 35 62 66 68 71 72 75 77 85 87 90 91 94 96 100
ThreeAPFree[n_, k_, a_] := Module[{d, j}, For[d = 1, d < k/2, d ++, For[j = 1, j <= n - 2, j++, If[MemberQ[a, a[[j]] + d] && MemberQ[a, a[[j]] + 2 d], Return[False]]]]; Return[True]]; A065825[n_] := Module[{k, x, a}, k = n; While[True, x = Subsets[Range[k], {n}]; For[i = 1, i <= Length[x], i++, a = x[[i]]; If[a[[1]] != 1 || a[[n]] != k, Continue[]]; If[ThreeAPFree[n, k, a], Return[k]]]; k++]] Table[A065825[n], {n, 1, 10}] (* Robert Price, Mar 11 2019 *)
\\ brute force has3AP(v)=for(i=1,#v-2,for(j=i+2,#v,my(t=(v[i]+v[j])/2);if(denominator(t)==1 && setsearch(v,t),return([v[i],t,v[j]]))));0 a(n)=for(k=n,oo,forvec(u=vector(n,i,if(i==1,[1,1],i==k,[k,k],[2,k-1])),if(has3AP(u)==0, /* print(u); */ return(u[n])),2)) \\ Charles R Greathouse IV, Aug 04 2020
4 is out because of 1,2,3,4. 13 is out because of 1,5,9,13.
5 is out because of 1,2,3,4,5. 21 is out because of 1,6,11,16,21.
Example for n=13: { 1, 2, 3, 5, 6, 8, 9, 10, 16, 17, 18, 20, 21 } with span 20.
Comments