0

I'm writing a program where one part of it has to calculate a LCM with "shifted" values.

The idea behind it is quite hard to describe for me, so I'll give you an imaginative representation of it:

Imagine we have got two sets of bricks: one of 20cm height white bricks and another with 30cm height black bricks. We are building two "towers" out of each set until we got two towers of the same height. The question is: how tall will be each of towers?

Of course the answer is: $lcm(20,30) = 60$

Now the twist

Imagine one of those towers doesn't sit on the ground level, but it is positioned on a foundation that raises it by 5cm up. Now, because the towers are not of the same height, we start adding bricks again until they will be again of the same height.

The (real) question is: how much bricks we need NOW?

Felix.leg
  • 111
  • 3
    Welcome to MSE. $5+20n=30m$ has no integer solutions since $10$ divides the right side but not the left – J. W. Tanner Dec 20 '22 at 18:50
  • Can we assume that all the numbers involved (the two brick heights and the height of the foundation) are integers? – Michael Lugo Dec 20 '22 at 18:53
  • @MichaelLugo yes they are integers. – Felix.leg Dec 20 '22 at 18:54
  • With arbitrary shifts $,j,k,$ after rearranging the equality $,j+20a = k+30b,$ you end testing integer solvability of $,20a-30b = k-j,,$ which, by general theory in the linked dupe, is solvable $!\iff \gcd(20,30)=10\mid k-j,,$ i.e. iff the shifts are congruent $!\bmod 10\ \ $ – Bill Dubuque Dec 20 '22 at 19:07

1 Answers1

1

If one tower is shifted by $5$ cm, then the towers will never be of the same height,

no matter how many bricks you add.

The towers will be of height $5+20n$ and $30m$ (or $20n$ and $5+30m$),

where $n$ and $m$ are whole numbers,

and these will never be equal, because $10$ divides $30m$ (or $20n$) but not $5+20n$ (or $5+30m$).

J. W. Tanner
  • 60,406
  • So, for this to work, each side of the equal sign must has got at least one common divisor, right? What if the foundation would be 10cm instead? – Felix.leg Dec 20 '22 at 19:04
  • If the foundation were $10$ cm, then $10+20=30$, or $2\times20=10+30$; if the foundation were $1$ cm and the bricks were $9$ and $10$ cm, then $1+9=10$ – J. W. Tanner Dec 20 '22 at 19:05
  • Please strive not to post more (dupe) answers to dupes of FAQs, cf. recent site policy announcement here. – Bill Dubuque Dec 20 '22 at 19:08
  • @BillDubuque: I have been striving, but here OP asked a question about bricks, towers, and LCMs, which I answered, and I don't know that OP knows or cares about linear congruences, modular inverses, or Bezout equations per se – J. W. Tanner Dec 20 '22 at 19:28
  • But the OP does not need to understand anything about linear congruences, modular inverses, or Bezout equations because the direction $(\Rightarrow)$ that yields the solvability criterion in the (half-line) proof in the linked dupe uses only a basic divisibility inference. Your proof is a special case of that proof. – Bill Dubuque Dec 20 '22 at 19:43