calc GCD (greatest common divisor) and LCM (least common multiple) inside gen~


    Dec 19 2016 | 2:18 pm
    Dear Friends
    Can I calc - as mentioned in the topic's title - GCD (greatest common divisor) and LCM (least common multiple) of two values inside gen~?
    thanks in advance for any indications

    • Dec 19 2016 | 4:11 pm
      You'll need to use a codebox, as these require an iterative procedure, i.e. a for loop, and then implement one of the typical algorithms. Once you have GCD, LCM is easy:
    • Dec 19 2016 | 4:15 pm
      That's really elegant. Thank you so much, Graham.
    • Aug 16 2020 | 11:45 pm
      FWIW, 4 yrs later, I did this with these. Given how integral this is, I'm very curious why there aren't GCD and LCM objects in max.
      hemiola.zip
    • Aug 17 2020 | 5:05 am
      GCD = % until rest is 0, then it is the last div?
    • Aug 17 2020 | 12:27 pm
      R, That would be the implication of Graham's gen patch that I used.