added fast, complete version of problem 34