0

I have a series of constraints: A, B, C, etc. Any number is valid if when divided by ALL of them (one at a time) will result in an integer.

Is there any reliable generic way to combine the series A, B, C etc to a common number that is the LEAST possible common value that will serve as a single constraint so I don't have to perform the validation check on all of the constraints?

A practical example: A,B,C = 2,4,5

Manually I can figure out that the common constraint is 20. That's when they first intersect so to speak.

A, B, C etc can be ANY number strictly greater than 0, including non integers.

Is this at all possible?

  • Are you familiar with GCD and LCM? – John Lou Oct 20 '17 at 18:50
  • No, I realize that I probably could have explained my question in better terms, but I am limited in my understanding. – Martin Hansen Oct 20 '17 at 18:51
  • http://www.purplemath.com/modules/lcm_gcf.htm Check this out. You're describing an operation that is already defined :) – John Lou Oct 20 '17 at 18:53
  • LCM is what I'm looking for, if I just knew the name my googling effort would have paid off earlier. Thanks! Found several libraries that compute the lcm for me now: https://www.npmjs.com/search?q=lcm But they all seem to require integers. Can it be done with numbers between 0 and 1? Multiply by 10 until there are only integers and then later divide by the same? – Martin Hansen Oct 20 '17 at 19:04
  • 1
    LCM and GCD require integers. I guess that would work for you tho. – John Lou Oct 20 '17 at 19:05

0 Answers0