login
Number of distinct nonzero Fibonacci numbers in the numerator of the 2^n sums generated from the set 1, 1/2, 1/3, ..., 1/n.
4

%I #33 Feb 16 2022 09:21:22

%S 1,2,3,4,5,6,8,8,8,12,12,13,13,13,13,15,15,15,17,17,17,19,21,21,23,24,

%T 25,25,25,25,25,27

%N Number of distinct nonzero Fibonacci numbers in the numerator of the 2^n sums generated from the set 1, 1/2, 1/3, ..., 1/n.

%C For the largest generated Fibonacci number, see A256222. For the smallest Fibonacci number not generated, see A256223.

%e a(4) = 4 because 4 sums yield distinct Fibonacci numerators: 1, 1 + 1/2 = 3/2, 1/2 + 1/3 = 5/6 and 1/2 + 1/3 + 1/4 = 13/12.

%p S:= {0,1}: N:= {1}:

%p nfibs:= 10:

%p fibs:= {seq(combinat:-fibonacci(n),n=1..nfibs)}:

%p A[1]:= 1:

%p fibnums:= {1}:

%p for n from 2 to 24 do

%p Sp:= map(`+`,S,1/n);

%p N:= N union map(numer, Sp);

%p Nmax:= max(N);

%p S:= S union Sp;

%p while combinat:-fibonacci(nfibs) < Nmax do nfibs:= nfibs+1; fibs:= fibs union {combinat:-fibonacci(nfibs)} od;

%p newfibnums:= N intersect fibs;

%p fibnums:= newfibnums;

%p A[n]:= nops(fibnums);

%p od:

%p seq(A[n],n=1..24); # _Robert Israel_, Dec 09 2016

%t <<"DiscreteMath`Combinatorica`";maxN=23; For[prms={}; i=0; n=1, n<=maxN, n++, While[i<2^n-1, i++; s=NthSubset[i, Range[n]]; k=Numerator[Plus@@(1/s)]; If[IntegerQ[Sqrt[5*k^2+4]]||IntegerQ[Sqrt[5*k^2-4]],prms=Union[prms, {k}]]]; Print[Length[prms]]]

%o (Python)

%o from math import gcd, lcm

%o from itertools import combinations

%o def A256221(n):

%o m = lcm(*range(1,n+1))

%o fset, fibset, mlist = set(), set(), tuple(m//i for i in range(1,n+1))

%o a, b, k = 0, 1, sum(mlist)

%o while b <= k:

%o fibset.add(b)

%o a, b = b, a+b

%o for l in range(1,n//2+1):

%o for p in combinations(mlist,l):

%o s = sum(p)

%o if (t := s//gcd(s,m)) in fibset:

%o fset.add(t)

%o if 2*l != n and (t := (k-s)//gcd(k-s,m)) in fibset:

%o fset.add(t)

%o if (t:= k//gcd(k,m)) in fibset: fset.add(t)

%o return len(fset) # _Chai Wah Wu_, Feb 15 2022

%Y Cf. A000045, A075189, A010056, A256220, A256222, A256223.

%K nonn,more

%O 1,2

%A _Michel Lagneau_, Mar 19 2015

%E Corrected and more terms added by _Robert Israel_, Dec 09 2016

%E a(29)-a(31) from _Chai Wah Wu_, Feb 15 2022

%E a(32) from _Chai Wah Wu_, Feb 16 2022