## Counting until two numbers match

Dec 9, 2011 at 8:29pm

# Counting until two numbers match

Hi all!

I’m working on a Rhythm generator which works using two inputed numbers.

Two numbers are multiplied by themselves to create two lists of essentially, times tables. e.g:

3, 6, 9, 12, 15 etc
5, 10, 15, 20 etc

With any combination of numbers eventually two numbers will match. In the example above the number is 15. But the two lists vary in lengths

I want to enter two numbers and count up until the matching number is found.

Any help would be grand!!

Guy

(Using MAX/MSP 5 on Windows 7)

###### Attachments:
1. Matchingnumbers.maxpat
#60588
Dec 9, 2011 at 9:29pm

I’m unclear about what you’re trying to do here. Are you trying to find something like the lowest common denominator between the two numbers?

You use the word count, but where does counting come in?

#218042
Dec 9, 2011 at 10:15pm

Hi Chris,

Yes, I am trying to find the lowest common denominator!
(apologies for my poor knowledge of maths!!)

In the patch, the user “counts” by pressing the green button, this adds the numbers to the coll list.

If I could work out the lowest common denominator of the two numbers then I could use a counting object to bang the green button until the lowest common denominator appears in either list.

Does that make sense? I’m not very good at penning my thoughts!

#218043
Dec 9, 2011 at 11:14pm

just use [==] ? that would do it. You can match the numbers to each other, or check whether either one equals the LCM, assuming you have a way to easily determine that…checking whether the numbers “reduce” with each other (technically, do they share any prime factors and if so, don’t count them twice) will take a bit of fiddling with [%] and [/]. If you don’t have that many psosible combinations, you can just hard-code the LCM’s manually by figuring them out beforehand.

If you want more than two numbers, try [match]

Sounds like some interesting polyrhyms are on the way…math and music? yes indeed…!

#218044
Dec 10, 2011 at 7:23am

Hi,

I made an external that will give you the LCM of two arbitrary integers called `[sadam.lcm]`, which might help you with this. It is included in my library (see http://www.sadam.hu/software ).

Hope this helps,
Ádám

#218045
Dec 12, 2011 at 12:12pm

Thanks for everyones input!

#218046

You must be logged in to reply to this topic.