Implements first problem of chapter one