Lowest Common Denominator Algorithm

Warning message

The Propeller Object Exchange system is decommissioned and replaced with a GitHub repository to house the same existing and future Propeller objects. As of 12/5/2019, this site is read-only. You can continue to browse and download objects from here for a limited time; however, please begin using the Parallax Propeller repository for future reference.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Request group membership
By: created: 2013-11-24 | updated: 2013-11-24

This is a simple little method that returns the lowest common multiple of two numbers. For example, if I were to pass it the parameters (12,15), it would return 60. I use it as part of a CNC controller. It can only handle positive numbers. 

PUB Get_LCM (m,n) : result | a,b 'Returns lowest common multiple of two numbers
  a := m
  b := n
  repeat while a <> b
    if a < b
      a := (a+m)
    else
      b := (b+n)
result := a
 
Original File Upload
AttachmentSize
File GET_LCM.docx12.56 KB