Recursive Function Logic Math