Added iterative version, fixed greater/lower mistake for recursive version