computing min max function without recursion doing with DOLIST