Last digit problem from the programming competition.