%I #44 May 12 2021 12:59:13
%S 3,5,7,17,37,43,43,151,151,409,491,491,491,1087,2011,3709,3709,7417,
%T 7417,7417,19699,30139,35573,35573,40237,40237,132151,132151,158551,
%U 158551,245639,245639,961459,1674769,1674769,1674769,1674769,4339207
%N Smallest odd prime not occurring in the numerator of any of the 2^n subset sums generated from the set 1/1, 1/2, 1/3, ..., 1/n.
%C The largest prime generated is given in A075226. For information about how often the numerator of these sums is prime, see A075188 and A075189.
%e a(3) = 7 because 7 is the smallest prime not occurring in the numerator of any of the sums 1/1 + 1/2 = 3/2, 1/1 + 1/3 = 4/3, 1/2 + 1/3 = 5/6 and 1/1 + 1/2 + 1/3 = 11/6.
%t Needs["DiscreteMath`Combinatorica`"]; maxN=20; For[lst={}; 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[PrimeQ[k], AppendTo[prms, k]]]; prms=Union[prms]; j=2; While[MemberQ[prms, Prime[j]], j++ ]; AppendTo[lst, Prime[j]]]; lst
%t (* Second program; does not need Combinatorica *)
%t a[1] = 3; a[2] = 5; a[n_] := For[nums = (Total /@ Subsets[1/Range[n]]) // Numerator // Union // Select[#, PrimeQ]&; p = 3, p <= Last[nums], p = NextPrime[p], If[FreeQ[nums, p], Print[n, " ", p]; Return[p]]];
%t Table[a[n], {n, 1, 23}] (* _Jean-François Alcover_, Sep 10 2017 *)
%o (Haskell)
%o import Data.Ratio ((%), numerator)
%o import Data.Set (Set, empty, fromList, toList, union)
%o a075227 n = a075227_list !! (n-1)
%o a075227_list = f 1 empty a065091_list where
%o f x s ps = head qs : f (x + 1) (s `union` fromList hs) qs where
%o qs = foldl (flip del)
%o ps $ filter ((== 1) . a010051') $ map numerator hs
%o hs = map (+ 1 % x) $ 0 : toList s
%o del u vs'@(v:vs) = case compare u v
%o of LT -> vs'; EQ -> vs; GT -> v : del u vs
%o -- _Reinhard Zumkeller_, May 28 2013
%o (Python)
%o from sympy import sieve
%o from fractions import Fraction
%o fracs, newnums, primeset = {0}, {0}, set(sieve.primerange(3, 10**6+1))
%o for n in range(1, 24):
%o newfracs = set(Fraction(1, n) + f for f in fracs)
%o fracs |= newfracs
%o primeset -= set(f.numerator for f in newfracs)
%o print(min(primeset), end=", ") # _Michael S. Branicky_, May 09 2021
%Y Cf. A001008, A075135, A075188, A075189, A075226.
%Y Cf. A010051, A065091.
%Y Cf. A217712.
%K nonn,nice,more
%O 1,1
%A _T. D. Noe_, Sep 08 2002
%E a(21)-a(28) from _Reinhard Zumkeller_, May 28 2013
%E a(29)-a(33) from _Jon E. Schoenfield_, May 09 2021
%E a(34)-a(36) from _Michael S. Branicky_, May 10 2021
%E a(37)-a(38) from _Michael S. Branicky_, May 12 2021
|