Total = valueWithoutTax * (1 + TaxPercentage / 100)
t = x * (1 + p / 100)
So if x = 50 and p = 25% then:
t = 50 * (1 + 25 / 100)
t = 50 * (1 + 0.25)
t = 50 * 1.25
t = 62.5
Therefore:
x = t / (1 + p / 100)
So if the total t is 62.5 and the tax percentage is 25 then:
x = 62.5 / ( 1 + 25 / 100)
x = 62.5 / ( 1 + 0.25)
x = 62.5 / 1.25
x = 50
And the value of the tax is the difference between the total including tax (62.5) and the total excluding tax (50) == 12.5
That's all basic maths you are taught at what? Age 11? Younger?