A075188
Number of times that the numerator of a sum generated from the set 1, 1/2, 1/3,..., 1/n is prime.
Original entry on oeis.org
0, 1, 3, 9, 19, 43, 79, 162, 307, 607, 1075, 2186, 3872, 7573, 15101, 29139, 52295, 104953, 189915, 379275, 754081, 1462115, 2675851, 5351541, 10254019, 19987942, 38901233, 77620568, 144021667, 288428481, 537642772, 1056802340, 2113152353, 4138261885
Offset: 1
a(3) = 3 because 3 sums yield prime numerators: 1+1/2 = 3/2, 1/2+1/3 = 5/6 and 1+1/2+1/3 = 11/6.
-
import Data.Ratio (numerator)
a075188 n = a075188_list !! (n-1)
a075188_list = f 1 [] where
f x hs = (length $ filter ((== 1) . a010051') (map numerator hs')) :
f (x + 1) hs' where hs' = hs ++ map (+ recip x) (0 : hs)
-- Reinhard Zumkeller, May 28 2013
-
Needs["DiscreteMath`Combinatorica`"]; maxN=20; For[cnt=0; lst={}; 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], cnt++ ]]; AppendTo[lst, cnt]]; lst
A075189
Number of distinct primes in the numerator of the 2^n sums generated from the set 1, 1/2, 1/3, ..., 1/n.
Original entry on oeis.org
0, 1, 3, 6, 14, 20, 38, 74, 134, 232, 486, 526, 1078, 2036, 2505, 4762, 9929, 14598, 29831, 31521, 52223, 101123, 207892, 215796, 426772, 836665, 1640357, 1689653, 3401483, 3471770, 6868800, 13470379, 23182192, 45792615, 47136366
Offset: 1
a(3) = 3 because 3 sums yield distinct prime numerators: 1+1/2 = 3/2, 1/2+1/3 = 5/6 and 1+1/2+1/3 = 11/6.
-
import Data.Ratio ((%), numerator)
import Data.Set (Set, empty, fromList, toList, union, size)
a075189 n = a075189_list !! (n-1)
a075189_list = f 1 empty empty where
f x s s1 = size s1' : f (x + 1) (s `union` fromList hs) s1' where
s1' = s1 `union` fromList
(filter ((== 1) . a010051') $ map numerator hs)
hs = map (+ 1 % x) $ 0 : toList s
-- Reinhard Zumkeller, May 28 2013
-
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], prms=Union[prms, {k}]]]; AppendTo[lst, Length[prms]]]; lst
A075226
Largest prime in the numerator of the 2^n sums generated from the set 1, 1/2, 1/3,..., 1/n.
Original entry on oeis.org
3, 11, 19, 137, 137, 1019, 2143, 7129, 7129, 78167, 81401, 1085933, 1111673, 1165727, 2364487, 41325407, 41325407, 796326437, 809074601, 812400209, 822981689, 19174119571, 19652175721, 99554817251, 100483070801
Offset: 2
a(3) =11 because 11 is largest prime numerator in the three sums that yield primes: 1+1/2 = 3/2, 1/2+1/3 = 5/6 and 1+1/2+1/3 = 11/6.
-
import Data.Ratio (numerator)
a075226 n = a075226_list !! (n-1)
a075226_list = f 2 [recip 1] where
f x hs = (maximum $ filter ((== 1) . a010051') (map numerator hs')) :
f (x + 1) hs' where hs' = hs ++ map (+ recip x) hs
-- Reinhard Zumkeller, May 28 2013
-
Needs["DiscreteMath`Combinatorica`"]; maxN=20; For[t={}; lst={}; mx=0; i=0; n=2, n<=maxN, n++, While[i<2^n-1, i++; s=NthSubset[i, Range[n]]; k=Numerator[Plus@@(1/s)]; If[PrimeQ[k], If[k>mx, t=s]; mx=Max[mx, k]]]; Print[n, " ", t]; AppendTo[lst, mx]]; lst
Table[Max[Select[Numerator[Total/@Subsets[1/Range[n],{2,2^n}]],PrimeQ]],{n,2,30}] (* The program will take a long time to run. *) (* Harvey P. Dale, Jan 08 2019 *)
-
See Fuller link.
-
from math import gcd, lcm
from itertools import combinations
from sympy import isprime
def A075226(n):
m = lcm(*range(1,n+1))
c, mlist = 0, tuple(m//i for i in range(1,n+1))
for l in range(n,-1,-1):
if sum(mlist[:l]) < c:
break
for p in combinations(mlist,l):
s = sum(p)
s //= gcd(s,m)
if s > c and isprime(s):
c = s
return c # Chai Wah Wu, Feb 14 2022
A075227
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.
Original entry on oeis.org
3, 5, 7, 17, 37, 43, 43, 151, 151, 409, 491, 491, 491, 1087, 2011, 3709, 3709, 7417, 7417, 7417, 19699, 30139, 35573, 35573, 40237, 40237, 132151, 132151, 158551, 158551, 245639, 245639, 961459, 1674769, 1674769, 1674769, 1674769, 4339207
Offset: 1
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.
-
import Data.Ratio ((%), numerator)
import Data.Set (Set, empty, fromList, toList, union)
a075227 n = a075227_list !! (n-1)
a075227_list = f 1 empty a065091_list where
f x s ps = head qs : f (x + 1) (s `union` fromList hs) qs where
qs = foldl (flip del)
ps $ filter ((== 1) . a010051') $ map numerator hs
hs = map (+ 1 % x) $ 0 : toList s
del u vs'@(v:vs) = case compare u v
of LT -> vs'; EQ -> vs; GT -> v : del u vs
-- Reinhard Zumkeller, May 28 2013
-
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
(* Second program; does not need Combinatorica *)
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]]];
Table[a[n], {n, 1, 23}] (* Jean-François Alcover, Sep 10 2017 *)
-
from sympy import sieve
from fractions import Fraction
fracs, newnums, primeset = {0}, {0}, set(sieve.primerange(3, 10**6+1))
for n in range(1, 24):
newfracs = set(Fraction(1, n) + f for f in fracs)
fracs |= newfracs
primeset -= set(f.numerator for f in newfracs)
print(min(primeset), end=", ") # Michael S. Branicky, May 09 2021
Showing 1-4 of 4 results.
Comments