Brazil is better known for footballers than mathematicians, but amid the media feeding frenzy linked to the start of the World Cup next month it would be wrong to ignore the country's National Day of Mathematics on Tuesday. Author Alex Bellos tells the story of the man it honours.
Rio de Janeiro, 1925, and Brazil is on the up. Workers are building the city's landmark Christ the Redeemer statue. Samba, a new music, is becoming a national craze and the country's main newspaper, A Noite, introduces a new star writer with a story on the front page.
Malba Tahan - or, to give him his full name, Ali Iezid Izz-Edim Ibn Salim Hank Malba Tahan - was a Middle Eastern author who wrote in Arabic and was translated into Portuguese for the Brazilian market, readers were told. His short pieces were morality tales written in the style of the Arabian Nights, which soon began to touch on mathematical themes.
They were a huge success, and in 1932 Malba Tahan published what would became one of the most successful books ever written in Brazil - O Homem que Calculava - The Man Who Counted.
The book is set in the 13th Century, and begins: "In the name of Allah, the Most Beneficent, The Most Merciful! I was on the Baghdad road, returning at my camel's slow pace from an excursion to the famous city of Samarra, on the banks of the Tigris, when I saw a modestly dressed traveller, sitting on a rock, who looked like he was recuperating from a voyage."
The traveller is Beremiz Samir - a Persian mathematician - who joins the narrator on a journey that involves dozens of episodes in which he solves problems using his skill with numbers. At one point he visits the house of the king's minister, the Vizier Ibrahim Maluf.
"We passed through the heavy iron gate and down a narrow corridor… into the splendid inner garden of the palace. This garden, laid out exquisite taste, was shaded by two rows of orange trees. Passing through a variety of richly furnished rooms, hung with tapestries fringed in silver thread, we at last reached the rooms of the king's minister, who was reclining on large cushions and conversing with two friends."
Beremiz impresses the Vizier with an unusual way of counting a herd of camels - he counts the number of hooves and ears, then divides by six. The camels are a gift for the father of the Vizier's 16-year-old wife-to-be Astir, but Beremiz notices that one camel is missing an ear.
"I wanted to make a small suggestion," he says. "If you were to remove from the herd the defective animal, the total would be 256 which is the square of 16 (16 x 16). The gift offered to the father of the delightful Astir would then have a mathematical perfection, the number of camels equal to the square of the age of the beloved. The number 256 is an exact power of two - a number held to be symbolic by the ancients - while 257 is a prime number. These relations between squared numbers are good auguries for lovers."
I love the Man Who Counted. The book transports you into a magical world of Bedouins, viziers, sheiks, princes and kings, rich in references to Islamic traditions and locations in the Middle East. The maths is gentle, accessible and drives the stories.
It's mostly arithmetic, but there are geometrical puzzles too, and also curiosities like the magic square - a "square filled with numbers", which the Sultan presents to Beremiz after it has been salvaged from the house of a calligrapher.
"After studying both objects carefully, the Man Who Counted spoke as follows: 'This interesting square of numbers the calligrapher left behind is what we call a magic square. Let us take a square and divide it up into four or nine or 16 equal boxes. Put a number in each of these boxes. When the sum of the numbers in any line or column or diagonal always adds up to the same result, we have a magic square... The numbers in the separate boxes must all be different. It is impossible to construct a magic square with only four boxes.'"
He goes on to say that when a magic square can be rearranged into other magic squares, for example by moving the bottom row to the top, or the left-hand column to the right, it is called hypermagical. "Certain hypermagical squares are known as diabolicals," he adds.
Magic and diabolical
The Man Who Counted rightly became a bestseller and turned Malba Tahan into a household name - a mathematician as famous as Brazil's football stars.
And yet here's the thing. The book was a literary hoax. Malba Tahan never existed. He was the pen-name of Julio Cesar de Mello e Souza, a maths teacher from Rio de Janeiro who never set foot in the Middle East.
Mello e Souza was born in 1895. After studying engineering at college he taught maths and wrote short stories in his spare time. When he submitted his first stories to the local newspaper, they were turned down.
But when he changed the names and places in his stories, and resubmitted them to the newspaper saying they were translations of the fabulous US writer RS Slade, the newspaper printed them.
Mello e Souza realized that his only chance of success as a writer in Brazil was to use a foreign pseudonym. His love of maths had led him to a fascination with Islamic science and he decided to write stories about ancient Arabia using the nom de plume Malba Tahan.
Mello e Souza created an elaborate history for Malba Tahan. Born in 1885 near Mecca, he had travelled all over the world, including - bizarrely - a 12-year stint in Manchester where his father was a successful wine salesman. Malba Tahan had died fighting for the liberty of a group of Bedouins in the desert.
When Mello e Souza began writing as Malba Tahan, only the proprietor of the newspaper that printed the stories was in on the joke.
For several years no-one knew that the famous Arab author was actually a local maths teacher whose other passion was collecting porcelain frogs.
When eventually Malba Tahan was outed as humble Julio Cesar de Mello e Souza, however, he was famous enough for it not to matter.
His fans ranged from schoolchildren to the President of Brazil, and these days also include Brazil's most famous author, Paulo Coelho.
"He was a great storyteller," he says "I asked my family to buy all his books. Then one day I said, 'Oh my God this is such a fantastic person, I wish one day I would meet him.'"
The young Coelho was shocked when his parents revealed that the mysterious Arab author Malba Tahan was in fact a friend of theirs who lived just a few blocks away.
"I went to his house," Coelho recalls, "and I saw him and I shook hands, and he was of course I guess very flattered to know that a child of 10 years old was reading all his books.
"I did not dare to ask him to sign my books, because I was totally shy.
"Malba Tahan told us about this beautiful Arab culture, and he's so important today because tolerance is always present in his stories."
Mello e Souza wrote more than 100 books, about half of them recreational maths, and most of them set in the Islamic Middle East, although he also wrote stories about rabbis, Greeks, Chinese and Babylonians.
Yet despite his love of foreign cultures he only left Brazil twice, to go to Portugal and Argentina.
He died in 1974, by which time he had sold more than a million books in Brazil. The Man Who Counted remains his most famous, and it is still in print. My well-thumbed copy is the 74th edition. There are translations in Spanish, English and German.
And he's going to carry on being part of Brazilian culture since the government decreed, as of last year, that his birthday, 6 May, is the National Day of Mathematics.
Malba Tahan was called the "Brazilian of Arabia", and the "Pele of numbers". So did this all-Brazilian hero like football? Not really. He thought it was "a bit boring".
Maths, Islam and collecting toy frogs - that was a lot more fun.
Alex Bellos is the author of the mathematics book Alex Through the Looking Glass, and Futebol: The Brazilian Way of Life