# using Map to apply 2 lists to the LCM function - help [duplicate]

I have 2 lists of numbers and I want to quickly compute the array of answers to the LCM function for the 2 lists and a 3rd static number. I tried the following

list1 = {2,3,5,10};
list2 = {5,10,30,70};
LCM[37, #1, #2] & /@ [list1, list2]


but got a cryptic error message that I don't understand. Can anyone help or point me to the correct area?

## marked as duplicate by MarcoB, m_goldberg, Mr.Wizard♦Feb 4 '16 at 0:11

• Take a look at MapThread. – Kuba Feb 3 '16 at 21:01
• Table came to the rescue. lcmResults = ParallelTable[LCM[x, y, 37], {x, list1}, {y, list2}]; – Alan Woodward Feb 3 '16 at 21:12

You can use Outer along with Map.

Map[LCM[37, Sequence @@ #] &, Outer[List, list1, list2], {2}]
(*
{{370, 370, 1110, 2590},
{555, 1110, 1110, 7770},
{185, 370, 1110, 2590},
{370, 370, 1110, 2590}}
*)


Hope this helps.

Or as @SimonWood has pointed out in the comments.

Outer[LCM[37, ##] &, list1, list2]

• Why not just Outer[LCM[37, ##] &, list1, list2] ? – Simon Woods Feb 3 '16 at 21:27
• @SimonWoods Yes. You are completely correct. My solution-by-parts needs a convolution boost today. LOL!! – Edmund Feb 3 '16 at 21:30
• LOL. I wondered if you were just determined to use Map as specified in the question title... – Simon Woods Feb 3 '16 at 21:33
• @SimonWoods Perhaps subconsciously. :-P – Edmund Feb 3 '16 at 21:37

Example:

LCM[37, #[[1]], #[[2]]] & /@ Transpose[{list1, list2}]


or

MapThread[LCM[37, ##] &, {list1, list2}]


Output:

{370, 1110, 1110, 2590}


Reference: