Added a version that does tail recursion (tentatively looking into this) per bcrowder