Calcuater challenge from the Programmers Idea Book