%I #12 Nov 18 2020 09:03:06
%S 1,0,0,1,1,0,0,2,1,0,0,1,2,2,0,1,1,0,0,2,1,0,1,1,2,0,0,1,1,0,2,2,1,0,
%T 0,1,2,1,0,1,1,0,0,2,1,0,1,1,3,0,0,1,2,1,1,2,1,0,0,1,2,4,3,2,1,0,0,3,
%U 1,0,0,1,2,0,0,2,1,0,3,2,1,0,0,1,2,1,0,1,4,0,0,2,1,4,0,1,3,0
%N Number of different ways of drawing chords in a circle of numbers from 1 to n such that the sums of the numbers on the two sides of the chord are equal.
%H Alois P. Heinz, <a href="/A111143/b111143.txt">Table of n, a(n) for n = 2..10000</a>
%e a(5) = 1 because in a circle with the numbers from 1 to 5 we can put a chord from 1 and 4 and the sum of both sides is the same.
%e a(9) = 2 as in a circle with the numbers from 1 to 9 we can put a chord in two ways, one from 2 to 7 and another from 6 to 9.
%p a:= proc(n) local c, i, j, u, v;
%p c, i, j, u, v:= 0, 1, 2, 0, n*(n+1)/2-3;
%p while j<=n do
%p c:= c + `if`(u=v, 1, 0);
%p if u>v then u, v:= u-i-1, v+i; i:=i+1
%p else u, v:= u+j, v-j-1; j:=j+1
%p fi;
%p od; c
%p end:
%p seq(a(n), n=2..100); # _Alois P. Heinz_, Sep 12 2011
%t a[n_] := Module[{c = 0, i = 1, j = 2, u = 0, v = n(n+1)/2 - 3}, While[j <= n, c += If[u == v, 1, 0]; If[u > v, {u, v} = {u - i - 1, v + i}; i++, {u, v} = {u + j, v - j - 1}; j++]]; c];
%t a /@ Range[2, 100] (* _Jean-François Alcover_, Nov 18 2020, after _Alois P. Heinz_ *)
%K easy,nonn
%O 2,8
%A Joao B. Oliveira (oliveira(AT)inf.pucrs.br), Oct 18 2005
|