Message Boards Message Boards

1
|
3071 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

Factoring Pairs

Posted 11 years ago
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
2 Replies
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
Posted 11 years 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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract