The story is extraordinary. Even as the world was mired in medieval darkness, with the crushing hand of religion blocking all scientific inquiry, a lone genius named Fibonacci appeared on the shores of the Mediterranean. Through magnificent creative struggles, he discovered a number with near magical properties.

It is an infinite sequence that begins 1.61803… and is sometimes known as the Golden Ratio; sometimes as the Divine Proportion. Mathematicians symbolise it by the Greek letter phi, and it can be used to produce the most beautiful rectangle humans can recognise: one that already was understood when the Parthenon was designed and, in times to come, would be incorporated by Leonardo da Vinci in his greatest works of art. It appears today in the proportions even of the humble credit card.

Or so the internet, and many popular books, would have us believe. In fact, the man referred to in so many accounts, originally Leonardo of Pisa (Fibonacci came long after his death, from his family's name), was not much of a genius. Nor was he living in an age of ignorance. Nor does the shape that came to be associated with his name actually appear in Greek sculpture, or Renaissance art, or our Mastercards today.

The actual story – of how he got famous, and what he really did – is more interesting than the legend. Fibonacci was born in the 12th century, when a number of exceptionally efficient popes were organising Europe in a way that hadn't been managed for many generations. Armies were being sent – not always with great success – to conquer lands in the Middle East; universities were growing; trade, banking and technical innovation were at a peak.

But although a small amount of that innovation was generated internally, much of it arose because a handful of cities such as Pisa were managing to maintain small fleets that could link them with the far more advanced world that already existed across the Mediterranean. Centuries of Islamic civilisation had produced marvels most Europeans could only stare at in awe. The vessels that set out from Pisa were like primitive spaceships, reaching a distant planet where wonders could be glimpsed – and with good Italian acumen, quickly copied, or purchased, or sometimes just stolen, to be brought back to Europe's simple consumers for profit.

Fibonacci's father was a customs official who was living amid one of the Italian trading missions in Muslim north Africa, and when he sent for his son to join him, Fibonacci quickly noticed how backward the world he came from was. In particular, Europeans still used the same counting system that ancient Romans had. One was I, two was II, 10 was X, and 50 was L. To write the number 52, one had to write LII.

At first that doesn't seem too bad, but now try multiplying it by 10. Even the least numerate among us know that 52x10=520: it's so straightforward that it doesn't even seem like a calculation. In Roman numerals, though, one needs to multiply LII by X, and who can read off the answer from that?

North African Arabs and Berbers were already using the efficient system of twos and 10s and 50s; Fibonacci's father and the other Europeans were stuck with the unwieldy Roman numerals. The opportunity was ripe, and Fibonacci plucked it: he prepared manuscripts showing how the new counting system worked.

Keith Devlin doesn't leave the story there, though. Our number system of 50s and twos originated in India, and not solely for reasons we'd expect. The concept of "0", for example, seems to have first appeared in a treatise called the Brahmasphutasiddhanta – "The Opening of the Universe" – as part of a religious quest to explain how important changes could occur to the universe that left its essence intact.

In Baghdad in the early ninth century, these Indian concepts were taken further, with advances in algebraic manipulation without which modern science could not exist. These researchers, too, were motivated by a belief that it was their obligation to investigate God's immanence in the world, in this numerical way as much as any other.

And phi? In Fibonacci's mind, this was the least of his contributions. Its origin was a word problem he copied from yet another source, looking at the rate at which rabbits reproduce. The offspring can be counted by the sequence 1, 2, 3, 5, 8, 13, 21, each number created by adding together the two that went before it. Since this sequence arises naturally from how objects accumulate, it appears in a number of other places. Stare closely at sunflower heads or pinecones and you'll find spirals that follow it exactly.

Phi is generated by dividing any number in the sequence by the number that came before it: 8 divided by 5 is a rough approximation, 13 divided by 8 is better, 21 divided by 13 better still, and so on. However, as Devlin shows, the idea that Fibonacci discovered this ratio is bogus: many mathematicians before him had been aware of it. And its supposedly magical properties? It turns out to be a fantasy that phi describes the exact proportions of the Parthenon or Leonardo's paintings. A conclusion that will disappoint romantics, perhaps, but a useful reminder of the hold that dreams of a mystical truth lying just beyond our reach have always had over mankind.

David Bodanis's The Ten Commandments: And How They Shaped Our World is out in spring 2012