#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Non-Repeating Number Combinations

edited January 2018

If I have several variables, all changing on continuous cycles based on frameCount, how do I adjust their periods so that the same combination doesn't repeat itself too soon?

In a simple example, if translateX moves an object back and forth across the screen every 100 frames, rotateY turns it all the way around every 200 frames, and its hue cycles through the spectrum every 400 frames, I'm going to get the exact same position/angle/colour combination every 400 frames.

If I change to numbers that seem like they "don't go", like 177 frames for rotateY and 419 frames for the hue, my intuition says I'm going to get a much longer animation before it repeats itself, but I'm not sure what the mathematical principle is here or how I'd go about working out good numbers for, say, 6 variables, or what the total time before repeat would be.

Ideally, I'd be able to pick a repeat time and work backwards from there.

Relevant link: https://longplayer.org/, a musical composition which apparently repeats itself every 1000 years by using multiple overlapping tracks. I'm only looking to do 45 minutes or so, so it should be easy!

Tagged:

• I think you're just looking for the least common multiple, aren't you?

The least common multiple of 3, 4, and 5 is 60. The least common multiple of 100, 200, and 400 is 400.

The least common multiple of 177 and 419 is 74163.

• Yes, that's the one! Thanks.

So now I know what that's called I can go to Wolfram Alpha and type "lcm(100,177,419)" to find the least common multiple.

Is there a way to work backwards, for example if I want a duration of 108,000 frames and I have 5 variables?

• 5 * 9 * 11 * 13 * 17 => 109395

6 * 9 * 11 * 13 * 14 => 108108

• edited February 2018 Answer ✓

Is your goal the minimum for each period, or do you want maximum variability in period lengths (one very short, like 2, and one very long, like 500)? Is your goal that each period be unique, or can two be the same (10, 10)?

For example, if you have five variables with a period of 1, 1, 1, 1, and 108,000, then they won't repeat until 108,000, but that isn't what you want.

Some sets of requirements also won't have exact solutions, so you should specify if you want just above or just below your time cutoff (it sounds like just above?). For example, 104729 is a prime number. There is no combination of five unique factors that can produce that number.

@koogs already demonstrated using combinations of numbers to build answers above and below your target.

If you are trying to be exact and unique and you need 108,000 specifically, then these are the factors you have to work with:

For example:

``````2 * 4 *  5 * 25 * 108 = 108,000
2 * 4 *  5 * 50 * 54 =  108,000
2 * 4 * 10 * 25 * 54 =  108,000
2 * 4 * 10 * 50 * 27 =  108,000
2 * 4 * 20 * 25 * 27 =  108,000
2 * 8 *  5 * 25 * 54 =  108,000
2 * 8 *  5 * 50 * 27 =  108,000
2 * 8 * 10 * 25 * 27 =  108,000
4 * 5 *  8 * 25 * 27 =  108,000
``````

More conceptually:

The prime factorization of 108,000 is `2^5 * 3^3 * 5^3`. You want 5 numbers, you have five 2s, three 3s, and three 5s to work with. Mix and match those eleven components into your five buckets -- you may choose the additional requirement that each bucket's value must be unique. If you have fewer primes than buckets, or if they cannot be unique (8 in three buckets must be 2,2,2), then the process fails.

• Thanks Jeremy!

To explain what I'm trying to do...

I want to be able to explore the range of combinations in the time available - so for example, if the combination of variable A at its maximum with variables B to E at their minimum produces a unique visual result, then I want to make sure that that combination happens once.

I guess that a very narrowly separated range of variables like 11x12x13x14x15 would fulfil this requirement, but it might be kindof boring to watch, since it will progress through the range of combinations slowly and in sequence.

I think your idea of mixing and matching prime factors into buckets gives me the flexibility I'll need to work this out.