Find the subtotal from the total including tax

If I have the Grand Total (including VAT) amount of money paid and the VAT % which was paid, how can I figure out the sub total (total before VAT)?

For example

If Sub Total = 70 and VAT is 18% (70*18% = 12.6) Then total = 70+12.6 = 82.6

Now if I was given the Total 82.6 and VAT 18%, how can I find sub total?

A programmatic answer is also accepted as it's what I'm looking for.

-

1. Assume that your sub total is $x$.
2. Add VAT to it $x + 18 \% \text{ of } x = x + 0.18 x$.
3. Now since this is your total, equate it to your total. i.e. $x + 0.18 x = 82.6$.
4. Now, we have $1.18 x = 82.6$, and I guess we can find this $x$.
@rikket $x = \frac{\text{total}}{1 + \frac{\text{VAT}}{100}}$ –  Santosh Linkha Jan 11 '13 at 22:29