Prime numbers are found hidden in nature, but humans have made spectacular use of them, writes mathematician Marcus du Sautoy.

Ever since humans evolved on this planet we have been trying to make sense of the world around us.

We have attempted to explain why the world looks and behaves the way it does, to predict what the future holds. And in our search for answers we have uncovered a code that makes sense of the huge complexity that confronts us - mathematics.

By translating nature into the code of numbers we have revealed hidden structures and patterns that control our environment.

But not only that. By tapping into nature's code we have been able to change our surroundings, have built extraordinary cities, and developed amazing technology that has resulted in the modern world.

Buzzing quietly beneath the planet we inhabit is an unseen world of numbers, patterns and geometry. Mathematics is the code that makes sense of our universe.

Find out more The first episode of The Code, presented by Marcus du Sautoy is on BBC Two at 21:00 BST on Wednesday 27 July Catch up later via iPlayer The Code homepage Revealing the code

In the forests of Tennessee this summer, part of this code literally bursts from the ground. Nashville is usually home to the sound of blue grass and honky tonk.

But every 13 years, the banjos and basses get drowned out for six weeks by the chorus of an insect that has fascinated me ever since I became a mathematician. Only found in the eastern areas of North America, this cicadas survival depends on exploiting the strange properties of some of the most fundamental numbers in mathematics - the primes, numbers that are only divisible by themselves and one.

The cicadas appear periodically but only emerge after a prime number of years. In the case of the brood appearing around Nashville this year, 13 years. The forests have been quiet for 12 years since the last invasion of these mathematical bugs in 1998 and the locals won't be disturbed by them again until 2024.

This choice of a 13-year cycle doesn't seem too arbitrary. There are another two broods across north America that also have this 13-year life cycle, appearing in different regions and different years. In addition there are another 12 broods that appear every 17 years.

Primes are the atoms of the arithmetic - the hydrogen and oxygen of the world of numbers Marcus du Sautoy

You could just dismiss these numbers as random. But it's very curious that there are no cicadas with 12, 14, 15, 16 or 18-year life cycles. However look at these cicadas through the mathematician's eyes and a pattern begins to emerge.

Because 13 and 17 are both indivisible this gives the cicadas an evolutionary advantage as primes are helpful in avoiding other animals with periodic behaviour. Suppose for example that a predator appears every six years in the forest. Then a cicada with an eight or nine-year life cycle will coincide with the predator much more often than a cicada with a seven-year prime life cycle.

These insects are tapping into the code of mathematics for their survival. The cicadas unwittingly discovered the primes using evolutionary tactics but humans have understood that these numbers not just the key to survival but are the very building blocks of the code of mathematics.

Every number is built by multiplying primes together and from numbers you get mathematics and from mathematics you get the whole of science.

But humans haven't been content simply with observing the importance of these numbers to nature. By understanding the fundamental character of these numbers and exploring their properties humans have literally put them at the heart of the codes that currently protect the world's cyber-secrets.

The Code Challenge A treasure hunt is running alongside the show

There are three visual clues in each episode as well as other clues

The prize is a specially commissioned mathematical sculpture The Code treasure hunt

The cryptography that keeps our credit cards secure when we shop online exploits the same numbers that protect the cicadas in North America - the primes.

Every time you send your credit card number to a website your are depending on primes to keep your details secret. To encode your credit card number your computer receives a public number N from the website, which it uses to perform a calculation with your credit card number.

This scrambles your details so that the encoded message can be sent across the internet. But to decode the message the website uses the primes which divide N to undo the calculation. Although N is public, the primes which divide N are the secret keys which unlock the secret.

The reason this is so secure is that although it is easy to multiply two prime numbers together it is almost impossible to pull them apart. For example no one has been able to find the two primes which divide the following 617-digit number:

25,195,908,475,657,893,494,027,183,240,048,398,571,429,282,126,204,

032,027,777,137,836,043,662,020,707,595,556,264,018,525,880,784,406,

918,290,641,249,515,082,189,298,559,149,176,184,502,808,489,120,072,

844,992,687,392,807,287,776,735,971,418,347,270,261,896,375,014,971,

824,691,165,077,613,379,859,095,700,097,330,459,748,808,428,401,797,

429,100,642,458,691,817,195,118,746,121,515,172,654,632,282,216,869,

987,549,182,422,433,637,259,085,141,865,462,043,576,798,423,387,184,

774,447,920,739,934,236,584,823,824,281,198,163,815,010,674,810,451,

660,377,306,056,201,619,676,256,133,844,143,603,833,904,414,952,634,

432,190,114,657,544,454,178,424,020,924,616,515,723,350,778,707,749,

817,125,772,467,962,926,386,356,373,289,912,154,831,438,167,899,885,

040,445,364,023,527,381,951,378,636,564,391,212,010,397,122,822,120,

720,357

The primes are the atoms of the arithmetic. The hydrogen and oxygen of the world of numbers.

But despite their fundamental character they also represent one of the greatest enigmas in mathematics. Because as you count through the universe of numbers it is almost impossible to spot a pattern that will help you to predict where the next prime will be found.

We know primes go on for ever but finding a pattern in the primes is one of the biggest mysteries in mathematics. A million-dollar prize has been offered to anyone who can reveal the secret of these numbers.

Despite having cracked so much of nature's code the primes are as much an enigma today as when the cicadas in the forests of Tennessee first tapped into them for their evolutionary survival.