0

I have achieved calculating normal lcm for any number of int. But what I want is more like a "special" lcm - don't know how to discribe this better, I'd appreciate someone could improve the question.

For example: I have {15, 21}
The "normal" lcm would be 105 = 15 x 7 = 21 x 5
What I want is 45 = 15 x 3 ≈ 44 ( 21 x 2 )

Another more complicated example: { 11, 14, 15, 16, 31 }
What I want is 33 = 11 x 3 ≈ 32 ( 16 x 2 ) ≈ 31 ≈ 30 ( 15 x 2 ) ≈ 28 ( 14 x 2 )

The calculated special lcm can not be smaller than the real multiple of any given number. For example 28 is smaller than 33 (let's say it can't be smaller than that - maximum difference amount is 5)

It's not hard to do this kind of calculation by hand, but how can I turn this into a program?

RadarNyan
  • 306
  • 1
  • 2
  • 12
  • If you want to do that, then theoretically wouldn't *every* result simply be the highest value of all the inputs since you could just round the other values up to that one? So lcm(14, 16, 31) = 31 since you can just round 14 and 16 up to 31 and the result will never have to be more than 31, thereby giving you the "smallest possible lcm" (whatever that means)... – BoltClock Jan 21 '17 at 03:47
  • *how can I turn this into a program?* By writing the code to do so. Do you have a **specific question** that we can answer? Rather than assuming we understand what you mean by *lcm*, you shoud explain clearly what you need help with, and ask a clear, specific question. – Ken White Jan 21 '17 at 06:47
  • @Ken White - Sorry if that statement annoys you. The code I currently have is nothing more than a caltulator for LCM / GCD (using "Euclidean algorithm"). The best way I can discribe what I want to achive is by using examples. I don't even know how to start, some hint would be appreciated. – RadarNyan Jan 21 '17 at 07:20

0 Answers0