%I #24 Feb 21 2021 14:08:33
%S 0,1,2,2,2,2,4,3,4,4,4,4,4,4,6,4,6,5,8,6,8,6,8,6,8,7,8,8,8,8,8,8,9,8,
%T 10,9,10,10,12,10,11,9,12,9,12,10,12,10,13,10,14,11,14,11,16,11,16,12,
%U 16,12,16,13,16,13,16,14,16,13,16,14,18,14,16,14,20,14,16,14,20,15,18
%N Size of the largest subset of the numbers [1..n] which does not contain a 3-term arithmetic progression modulo n.
%C This is similar to A003002, but the arithmetic progression is modulo n here.
%C For n >= 3, a(n) can be viewed as the maximum number of vertices that can be chosen from a regular polygon with n sides so that no three of them form an isosceles or equilateral triangle.
%H Math StackExchange, <a href="https://math.stackexchange.com/questions/4012158/number-of-points-chosen-form-a-polygon-to-have-no-isosceles-and-equilateral-tria">A question about this sequence</a>.
%e n, a(n), example of an optimal subset:
%e 0, 0, {}
%e 1, 1, {1}
%e 2, 2, {1,2}
%e 3, 2, {1,2}
%e 4, 2, {1,2}
%e 5, 2, {1,2}
%e 6, 4, {1,2,4,5}
%e 7, 3, {1,2,4}
%e 8, 4, {1,2,4,5}
%e 9, 4, {1,2,4,5}
%e 10, 4, {1,2,4,5}
%e 11, 4, {1,2,4,5}
%e 12, 4, {1,2,4,5}
%e 13, 4, {1,2,4,5}
%e 14, 6, {1,2,4,8,9,11}
%e 15, 4, {1,2,4,5}
%e 16, 6, {1,3,4,8,9,11}
%e 17, 5, {1,2,6,7,9}
%e 18, 8, {1,2,4,5,10,11,13,14}
%e 19, 6, {1,3,4,8,9,11}
%e 20, 8, {1,2,4,5,11,12,14,15}
%o (C) /* For n >= 3: */
%o int a(int n)
%o {
%o int upp, maxb, s, i, l, h, maxs;
%o uint64_t b, bs, m, mv[31], mn;
%o for (l = 1; l <= 31; l++) { mv[l - 1] = 1 << 2*l; mv[l - 1] |= (1 << l); mv[l - 1] |= 1; }
%o maxb = 1 << n; mn = maxb - 1; h = (n - 1) / 2; maxs = 2*n/3; upp = 0;
%o for (b = 0; b < maxb; b++) {
%o for (i = 0, s = 0, m = 1; i < n; i++, m <<= 1) { if (b & m) s++; }
%o if (s <= maxs) {
%o for (l = 1; l <= h; l++) {
%o m = mv[l - 1];
%o for (i = 0; i < n; i++) { if ((b & m) == m) { l = 1000; break; } m = ((m << 1) & mn) | (m >> (n - 1)); }
%o }
%o if (l < 1000 && s > upp) upp = s;
%o }
%o }
%o return upp;
%o }
%Y Cf. A003002.
%K nonn,more
%O 0,3
%A _Fabio VisonĂ _, Feb 15 2021
%E a(31)-a(80) from _Bert Dobbelaere_, Feb 20 2021
|