Solve problem 25 using C++ and Python.