Where have I gone wrong with my int maths?