# factorization of integer into two parts with specific prime factors

I would like to write a Mathematica code to decompose an integer into two or more parts with primes in special intervals.

For instance, I want to decompose $m=\binom{n}{k}$ into two parts U and V such that $\binom{n}{k}=UV$ and $$U=\prod_{\substack{p\le k\\p^\alpha||m}} p^{\alpha}$$ and $$V=\prod_{\substack{k<p\le n\\p^\alpha||m}} p^{\alpha}$$ where $p^\alpha||m$ mean $p^\alpha$ is the maximum prime power dividing m.

I tried

Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,2,k-1}]

Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,k,n}]


, but it was not true

• @ Öskå, I want the Mathematica code to do this
Aug 6, 2014 at 11:15
• Have you tried anything? Or do you expect an answer without producing any relevant effort?
– Öskå
Aug 6, 2014 at 11:25
• I tried >>Product[If[Mod[Binomial[n, k], p] == 0, p, 1], {p,k,n}], but it was not true
Aug 6, 2014 at 17:10

@asad the comments are all appropriate and (if I understand your aim), I present a way to implement to perhaps kickstart your own approach. However, I suggest in future you post an attempt, however imperfect. Further, it is helpful to post a small example so people can be clear about what you mean. Finally, if I misunderstand your aim then comment, otherwise I hope this motivates you try your own code, improve, modify etc. Otherwise, your future questions will probably fall on deaf ears...but more importantly you will not develop your own experience.

Function:

dec[n_, k_] := Module[
{num, u},
num = Binomial[n, k];
u = Times @@ (#1^#2 & @@@
Cases[FactorInteger[num], {_?(# < k &), _}]); # ->
Times @@ (HoldForm[#1^#2] & @@@ (FactorInteger@#)) & /@ {u,
num/u}]


Example:

grd = Grid[
Table[{StyleBox[RowBox[{"(", GridBox[{{17}, {j}}], ")"}],
SpanMaxSize -> Infinity] // DisplayForm, Binomial[17, j],
dec[17, j]}, {j, 1, 17}], Frame -> All]


The following function splits m=Binomial[n,k] into one or two parts whose product is m. The parts satisfy the conditions you specified, to the best of my understanding.

UVfactors[n_, k_] :=
With[{f = FactorInteger[Binomial[n, k]]},
Print[Binomial[n, k]];
Print[f];
Apply[Times,
Map[#[[All,1]]^#[[All,2]]&, SplitBy[f, UnitStep[k - #[[1]]]&]],
1]
]


Since I like using operator forms without slots, I will give another answer:

UVsplit[n_, k_] := Values @ GroupBy[
FactorInteger @ Binomial[n, k],
LessEqualThan[k] @* First,
Apply[Times] @* Map[Apply[Power]]
]


For example:

UVsplit[17, 11]


{56, 221}