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