The Python Oracle

Are two integers equal in SOME base?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Track title: CC O Beethoven - Piano Sonata No 3 in C

--

Chapters
00:00 Are Two Integers Equal In Some Base?
03:27 Accepted Answer Score 3
04:02 Thank you

--

Full question
https://stackoverflow.com/questions/3536...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #algorithm #math

#avk47



ACCEPTED ANSWER

Score 3


You can make the problem simpler by applying a little bit of number of theory. Taking your first example 13x7=28 we can expand this out into an explicit polynomial over the base: (1n+3)*7=2n+8.

If this solution has real roots then the roots are values of n (bases) for which the equation is true. If you like this sort of problem then you should read Computational Number Theory by Shoup. It's a fun book.