Updated to fix a bug pointed out by DanielLichtblau
The restriction $\frac{j}{\gcd(j, i)}$ is composite means that $j$ must contain at least two prime factors not in $i$. The following function encodes this restriction:
restriction[n_] := With[{fi=FactorInteger[n]},
Total[Ramp[#2-f[#1]]& @@@ fi] >= 2
]
For example:
restriction[12]
Ramp[2 - f[2]] + Ramp[1 - f[3]] >= 2
The above says that the prime factorization of $i$ can have no factor of 2 (and any power of 3), or it can have 1 factor of 2 and no factor of 3. Applying this restriction for each element of $L$, and also specifying that the exponents must be nonnegative yields:
allowed[set_List] := With[{restrict = restriction /@ set},
With[{ff = Cases[restrict, _f, Infinity] //Union},
Reduce[And @@ restrict && And @@ Thread[ff >= 0], ff, Integers]
]
]
For example:
allowed[{4, 12, 21}]
f[2] == 0 && f[3] == 0 && f[7] == 0
This says that the exponents of 2, 3 and 7 must be 0, but the remaining exponents are not restricted. So, the set of elements $i$ consists of:
5^a 11^b 13^c 17^d 19^e 23^f
for all nonnegative integers $a, b, c, d, e,$ and $f$. Finally, using:
$$\sum _{a_1=0}^{\infty } \sum _{a_2=0}^{\infty } \cdots \sum _{a_k=0}^{\infty }\frac{1}{p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}}=\prod _{i=1}^k \frac{1}{1-\frac{1}{p_i}}$$
we obtain:
unrestrictedSum[p_List] := Times @@ (1/(1 - 1/p))
unrestrictedSum[{5, 11, 13, 17, 19, 23}]
96577/55296
Now, the allowed set can sometimes contain a parameter. For example:
allowed[{12}]
(f[2] == 1 && f[3] == 0) || (f[2] == 0 && f[3] == 1) || (f[2] == 0 &&
f[3] == 0) || (C[1] ∈ Integers && C[1] >= 2 && f[2] == 0 &&
f[3] == C[1])
Here is a function that sums up the reciprocal contributions of each Or element:
reciprocalSums[a_Or]:=With[{logical = LogicalExpand[a]},
Total[reciprocalSum /@ List @@ logical]
]
reciprocalSums[a_]:=reciprocalSum[a]
reciprocalSum[e_]:=Module[{fs = Cases[e, _f, Infinity] //Union, res, cs, n},
res = m /. First @ Solve[Reduce[m == Times @@ Replace[fs, f[n_]:>n^-f[n], {1}] && e, m], m, fs];
cs = Sequence @@ Cases[e, C[i_] >= l_ :> {n[i], l, Infinity}, Infinity];
res /. ConditionalExpression[m_, conds_] :> Sum @@ {m /. C[i_]:>n[i], cs}
]
For the above example we have:
reciprocalSums[allowed[{12}]]
2
Or, breaking it down to pieces:
reciprocalSum[f[2] == 1 && f[3] == 0]
reciprocalSum[f[2] == 0 && f[3] == 1]
reciprocalSum[f[2] == 0 && f[3] == 0]
reciprocalSum[C[1] ∈ Integers && C[1] >= 2 && f[2] == 0 && f[3] == C[1]]
1/2
1/3
1
1/6
Finally, packaging up the above as a function:
restrictedSum[set_, p_] := Module[{a = allowed[set], r, u},
r = Cases[a, f[q_]->q, Infinity]//Union;
u = Complement[Prime[Range[PrimePi[p]]], r];
reciprocalSums[a] unrestrictedSum[u]
]
Some examples:
restrictedSum[{8}, 23]
restrictedSum[{12}, 23]
restrictedSum[{25}, 23]
restrictedSum[{12 25}, 23]
restrictedSum[{12, 25}, 23]
restrictedSum[{12, 15}, 23]
676039/147456
676039/165888
676039/138240
49350847/8294400
676039/207360
676039/276480
This function should work for any set $L$. @DanielLichtblau's answer only works when the set $L$ is coprime, and in that case, my answer and his answer agree.
n
you want to test? The number of subsets grows quite rapidly... Moreover, are you sure that there will be anyi
satisfying your conditions? $\endgroup$:=
is not the way to set a variable (e.g.,p
) in Mathematica. Better usep = Prime[PrimePi[n]]
(have a look at the documentation aboutSetDelayed
and what it does). $\endgroup$n
, but perhaps I'd like to start with 28 (since I've resolved the problem for smallern
). Yes, there will always bei
's; for example, we can always takei=1
since thenj/GCD(1,j) = j
is composite for eachj
inL
. $\endgroup$i
? Otherwise, this going to be a very expensive way to compute many ones. Maybe you should give a detailed example for somen
in the question. This is a task in which one has to invest quite a lot of effort and people won't attack it without knowing that this will lead somewhere... $\endgroup$<= n/2
, anyi
consisting only of primes greater than or equal ton/2
will always work. E.g., ifn=12
, then for any choice ofL
, anyj
inL
has no prime factor larger than 5. So anyi
of the formi=7^a*11^b
will work since theGCD
will always be 1. This furnishes infinitely many values ofi
. For more examples ofi
, it will depend on the setL
. $\endgroup$