I want to solve this kind of problem:
I want to find the base of the system where this equation is true: 99 * 99 = 1210.
This equations seems to be written in the base, more than 10, so it's a bit confusing for me.
For bases, below 10 I am using the following methods in order to convert from Base P to base 10 or vise versa, but for bases above 10, seems that they don't work.
static int ConvertToPBase(int numberInTenBase, int P)
{
List<int> list = new List<int>();
while (numberInTenBase > 0)
{
list.Add((numberInTenBase % P));
numberInTenBase /= P;
}
list.Reverse();
string x = "";
foreach (var item in list)
{
x += item;
}
return Convert.ToInt32(x);
}
static int ConvertTo10BaseFromP(int P, int number)
{
int answer = 0;
string num = number.ToString();
for (int i = 0; i < num.Length; i++)
{
answer = answer * P + Convert.ToInt32(num[i].ToString());
}
return answer;
}