2 ms·
> I'm sure there's a bit more elegant way to find the missing thousand component, but for me it would be just quicker to do a bit of brute-forcing: The calcula
by gus_massa 11y ago
> I'm sure there's a bit more elegant way to find the missing thousand component, but for me it would be just quicker to do a bit of brute-forcing:
The calculation the author wants is
LastThreeDigits(secret*23) = 642
that is equivalent to
secret * 23 == 642 (mod 1000)
that is equivalent to
secret * 23 + dummy * 1000 = 642
The standard method is to solve this first for 1 instead of 642
other_secret * 23 + other_dummy * 1000 = 1
and this can be solved with the Extended Euclidean Algorithm: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
(But in this case, and with a computer, it's easier the brute force solution.)
- ronreiter 11y agoThanks!