Problem 1 from programmingpraxis.com.