Group Abstract Group Abstract

Message Boards Message Boards

Factoring Pairs

GROUPS:
We know that 30(2) = 60 or 15(4) = 60 or vice versa. How can I tell Mathematica to give all the factoring pairs of any number? In essence, I want to tell Mathematica 60 and have it give me 30(2) or 15(4) or vice versa.
POSTED BY: sean roubion
Answer
11 months ago
The function Divisors should help, for example
Divisors[60]

(* Out[1]= {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60} *)
Using this list, we can form the pairs {60/k, k} and display them in any desired way:
fact[n_Integer] := Row[{n/#, "(", #, ")"}] & /@ Take[#, Ceiling[Length[#]/2]] & @ Divisors[n]

fact[60]

(* Out[3]= {60(1), 30(2), 20(3), 15(4), 12(5), 10(6)} *)
POSTED BY: Ilian Gachevski
Answer
11 months ago
Or you could try this
n = 60; a = Divisors[n]; a = Select[a, # <= Sqrt[n] &]; b = Partition[Riffle[a, n/a], 2]
{{1, 60}, {2, 30}, {3, 20}, {4, 15}, {5, 12}, {6, 10}}

Paul.
POSTED BY: Paul Cleary
Answer
11 months ago