2
$\begingroup$

My first try to find all sets with LCM=n was this: i.e. $n=60$

k = 0;
n = 60;
For[i = 2, i <= Length[Subsets[Divisors[n]]], i++, 
If[Apply[LCM, Flatten[Take[Subsets[Divisors[n]], {i, i}]]] == n, 
k = k + 1]];
k    

and it worked for small $n$

then I found the OEIS series A076078 and there was this more efficient algorithm

f[n_] := Block[{d = Divisors[n]}, Plus @@ (MoebiusMu[n/d](2^DivisorSigma[0, d] - 1))]; 
f[60]

The problem is that I want $n$ to be a very large number.

In the comments on the OEIS page I found something very useful which I don't understand very well:

a(n)=1 iff n=1, a(p^k)=2^k, a(p*q)=10; where p & q are unique primes. a(n) cannot equal an odd number >1.

If m has more divisors than n, then a(m) > a(n).

If n is of the form p^rq^s where p & q are distinct primes and r & s are nonnegative integers then a(n)=2^(rs)(2^(r+s+1)-2^r-2^s+1).

Also if n=p_1^r_1*p_2^r_2*...*p_k^r_k where p_1,p_2,...,p_k are distinct primes and r_1,r_2,...,r_k are natural numbers then 2^(r_1*r_2*...*r_k)||a(n).

Can somebody explain 2^(r_1*r_2*...*r_k)||a(n) to me?

1 Answers 1

2

Note that your own code could be made orders of magnitude faster as follows:

Count[LCM @@@ Subsets[Divisors[n]][[2 ;;]], n]
(* Out: 3748 *)

For $n=60$, your code takes 4 seconds; the code above takes 6 milliseconds. This is still worse than the entirely different (and superior) approach you found on the OEIS page. In the end, in your approach (and mine above), the problem is Subsets, which becomes horribly expensive for large $n$.


|| is used here to mean "exactly divides" (Wikipedia list of math symbols). $a(n)$ on that page is the number of nonempty sets of distinct positive integers that have a least common multiple of $n$, i.e. the number you seek.

So that observation seems to translate to the following: if your integer $n$ can be expressed as a sum of prime powers, like the following $n=p_1^{r_1}+p_2^{r_2}+ \ldots +p_k^{r_k}$, for some primes $p_i$ and positive integers $r_i$, then $2^{(r_1 r_2\ \ldots \ r_k)}$ exactly divides $a(n)$.

How that can be used to calculate $a(n)$ is not immediately apparent to me, but more in general your question deals with the math, and not with Mathematica anyway.

  • 0
    In your penultimate paragraph, do you mean n can be expressed as a *product* of primes powers?2017-03-01