Drill

ProblemsGo › finance

Strip VAT out of a gross price

easyfinanceMathGo

A cashier sees the tax-inclusive total and must recover the net price the VAT was added on top of.

vatReversal(grossMinor: int, vatRatePercent: int) → int

Go needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

func vatReversal(grossMinor int, vatRatePercent int) int {
	
}

Worked examples

CallResult
vatReversal(1210, 10)1100
vatReversal(1000, 0)1000
vatReversal(2000, 25)1600
vatReversal(0, 10)0

Hint

Scale the gross by 100 and divide by the tax factor.

Reference solution in Go
func vatReversal(grossMinor int, vatRatePercent int) int {
	return grossMinor * 100 / (100 + vatRatePercent)
}

The same problem in another language

More finance problems in Go