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?