Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to find a base in order to have the same number represented in two different bases. For example, given 16947800 and 2372452, find a base b so that 16947800=2372452b

What I have tried:

The definition of a base, but that involves solving a polynomial equation of increasing degree, which proves too compute-intensive.
Posted
Updated 12-May-18 14:43pm

1 solution

Quote:
I need to find a base in order to have the same number represented in two different bases. For example, given 16947800 and 2372452, find a base b so that 16947800=2372452b

Why don't you try every possible bases ?
It take 16947800 and covert to the base you test.
Quote:
The definition of a base, but that involves solving a polynomial equation of increasing degree, which proves too compute-intensive.

What operation need 'solving a polynomial equation' ?
 
Share this answer
 
v4
Comments
SACC92 13-May-18 15:47pm    
I would need to convert very large numbers, of order 10^18, but your suggestion is actually helpful, as I was thinking the other way around, as in, take base b, then solve the equation, in this example, 2*b^6 + 3*b^5 + 7*b^4 + ... + 2 = 16947800. Your approach, as in doing it the other way around, seems far more effective. Do you think doing a search for the base with some sort of bisection algorithm for the base interval would work for large numbers as the ones I'll need to work with?
Patrice T 13-May-18 16:00pm    
My first approach is brut force, there is not so many bases to check.
If bases are between 10 and 500, dichotomy is ok.
Here, there is just a few bases to check.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900