%I #20 Apr 27 2021 11:23:09
%S 1,1,1,3,3,7,8,17,21,47,63,132,205,411,685,1353,2385,4643,8496,16430,
%T 30735,59343,112531,217245,415628,803209,1545463,2991191,5778267,
%U 11201883,21702708,42141575,81830748,159140895,309590883,602938098,1174779397,2290920127
%N Number of distinct hexaflexagons of length n.
%H Marshall Hampton, <a href="https://arxiv.org/abs/1704.07775">Constructing and Counting Hexaflexagons</a>, arXiv:1704.07775 [math.CO], 2017.
%p A286110 := proc(n)
%p if type(n,'odd') then
%p add(A052307(n,ceil(n/2)+1+3*i),i=0..n/6+1) ;
%p else
%p add(A052307(n,ceil(n/2)+3*i),i=0..n/6) ;
%p %-A052307(n,n/2)/2+A007148(n/2)/2-1
%p end if;
%p end proc:
%p seq(A286110(n),n=3..40) ; # _R. J. Mathar_, Jul 23 2017
%t A007148[n_] := (1/2)*(2^(n - 1) + Total[EulerPhi[2*#]*2^(n/#) & /@ Divisors[n]]/(2*n));
%t A052307[n_, k_] := Module[{hk = Mod[k, 2], a = 0}, If[k == 0, Return[1]]; Do[a = a + EulerPhi[d]*Binomial[n/d - 1, k/d - 1], {d, Divisors[GCD[k, n]]}]; (a/k + Binomial[Floor[(n - hk)/2], Floor[k/2]])/2];
%t a[n_] := Module[{s}, If[Mod[n, 2] == 1, Sum[A052307[n, Ceiling[n/2] + 1 + 3*i], {i, 0, Floor[n/6] + 1}], s = Sum[A052307[n, Ceiling[n/2] + 3*i], {i, 0, Floor[n/6] }]; s - A052307[n, n/2]/2 + A007148[n/2]/2 - 1]];
%t Table[a[n], {n, 3, 40}] (* _Jean-François Alcover_, Nov 28 2017, after _R. J. Mathar_ *)
%o (Python)
%o from sympy import binomial as C, totient, divisors, gcd, floor, ceiling
%o def a007148(n):
%o if n==1: return 1
%o return 2**(n - 2) + sum(totient(2*d)*2**(n//d) for d in divisors(n))//(4*n)
%o def a052307(n, k): return 1 if n==0 else C((n//2) - k%2 * (1 - n%2), (k//2))/2 + sum(totient(d)*C(n//d, k//d) for d in divisors(gcd(n, k)))/(2*n)
%o def a(n):
%o if n%2: return sum([a052307(n, ceiling(n/2) + 1 + 3*i) for i in range(n//6 + 2)])
%o else:
%o s=sum([a052307(n, ceiling(n/2) + 3*i) for i in range(n//6 + 1)])
%o return s - a052307(n, n//2)//2 + a007148(n//2)//2 - 1
%o print([a(n) for n in range(3, 41)]) # _Indranil Ghosh_, Jul 24 2017, after Maple code
%Y Cf. A007282, A286111.
%K nonn
%O 3,4
%A _Michel Marcus_, May 02 2017