added tail recursion, and interative version of tail recursion