This is an interesting topic. Probably the best author who wove mathematics into his stories was Lewis Carroll. You will find an interesting article here.
The article, from the New Scientist, describes how Lewis Carroll’s story was in fact making fun of the new mathematics of the 19th century. Lewis Carroll whose real name was Charles Dodgson was a mathematician at Christ Church College, Oxford. He was a traditionalist and took a dislike to the strange new mathematics of for example, complex numbers and other rapidly developing areas of mathematics.