https://www.b-forum.net/recurrent/rec038/#program