Simple algorithm program