algorithm 4th, first source code