From: Jari Williamsson Date: 2008-02-16T07:41:47+09:00 Subject: Re: Finding smallest integer division? Robert Klemme wrote: > On 15.02.2008 19:49, Jari Williamsson wrote: >> In Ruby, what would be the most efficient way to find the smallest >> number that an array of different numbers can be divided by with >> integer math? >> >> For example: >> [1,2] would return 2 >> [1,2,3] would return 6 >> [1,2,4] would return 4 >> [1,2,3,4] would return 12 > > Somehow your wording puzzles me: you write that you look for the > smallest number that an array can be divided by but yet you rather seem > to be looking for the smallest number that can be divided by all numbers > in the array. I think Rob is spot on with his suggestion. Yepp, I got it reversed. Using inject and lcm worked great! Best regards, Jari Williamsson