To be able to calculate 6-digit numbers, having hundreds of millions of line of code would be impractical even for a WTF application, and probably would fail the load and execution time constraints, as well as run out of system memory.
A more practical way is to make a case statement dealing with every possible binary operation of two single-digit numbers. When accepting multi-digit numbers, break them down into single-digits and work on each digit, carrying overflow over.
Pretty much exactly the way elementary school math works. But you can slap on top all kinds of "creative" twists, such as using recursive functions, remembering that multiplication is just fancy addition (same with subtraction).
Another wise idea: for division, you can implement a single function 1/X which returns the inverse of a given number (and lots of rooms for WTFs in it too), and then treat the result as a multiplication operand. (so dividing 12 by 7 would be multiplying 12 by 1/7)