Example |
Example:
2) 6: (2,3), (3,4), (8,9);
3) 30: (2,3), (2,5), (3,4), (3,5), (3,8), (4,5), (4,9), (5,6), (5,8), (8,9),
(9,10), (15,16), (24,25), (25,27), (27,32), (80,81), (125,128);
4) 210: (2,3), (2,5), (2,7), (2,9), (3,4), (3,5), (3,8), (3,10), (4,5), (4,7),
(4,9), (4,25), (5,6), (5,7), (5,8), (5,12), (6,7), (7,8), (7,9), (7,10),
(7,12), (8,9), (8,15), (9,10), (9,14), (9,16), (14,15), (15,16), (16,21),
(18,25), (20,21), (20,27), (24,25), (25,27), (25,28), (25,32), (27,28),
(27,32), (32,35), (35,36), (48,49), (49,50), (49,54), (49,64), (63,64),
(80,81), (125,126), (125,128), (128,135), (224,225), (243,245), (243,250),
(1024,1029), (2400,2401), (4374,4375);
...
|
Mathematica |
Block[{c, d, f, K, R},
f[n_, m_ : 0] :=
Block[{w , lim = If[m <= 0, n, m]},
Sort@ ToExpression@
Function[w,
StringJoin["Block[{n = ", ToString@ lim, "}, Flatten@ Table[",
StringJoin@
Riffle[Map[ToString@ #1 <> "^" <> ToString@ #2 & @@ # &,
w], " * "], ", ", Most@ Flatten@ Map[{#, ", "} &, #], "]]"] &@
MapIndexed[
Function[p,
StringJoin["{", ToString@ Last@ p, ", 0, Log[",
ToString@ First@ p, ", n/(",
ToString@
InputForm[
Times @@ Map[Power @@ # &, Take[w, First@ #2 - 1]]],
")]}"]]@ w[[First@ #2]] &, w]]@
Map[{#, ToExpression["p" <> ToString@ PrimePi@ #]} &, #[[All, 1]]
] &@ FactorInteger@ n
];
Map[(c = 0;
K = #;
R = f[K, (K^2)/2]; d = Divisors[K];
Map[Function[k,
c += Count[k + d, _?(And[CoprimeQ[k, #], MemberQ[R, #]] &)]],
Rest@ R]; c) &, Rest@ FoldList[Times, Prime@ Range[5]]]
] (* Michael De Vlieger, May 3 2016 *) |