If we want the memory consumption of an iterative approach and the elegance of a recursive implementation, then we would need to take a look at : Tail recursion! So, let’s start decoding this.
About the very basics of recursive function and stack overflow.
Understand endianness , detection and conversion from one form to another
About functions, their stack allocations and stack management by the system