New version of Python script.

Two versions. One of them includes memoization. It brings more satisfaction with large number of inputs than excercising with unappropriate data types.