One of the brightest mathematicians of his generation at Cambridge, Rees had begun postgraduate research in September 1939, when his undergraduate director of studies at Sidney Sussex College, Gordon Welchman, was recruited to work at Bletchley.
Welchman set up Hut 6, the section breaking German army and air force Enigma ciphers, and recruited a number of promising Cambridge mathematicians to work with him. They included Rees, who was immediately put to work in the Hut 6 Machine Room, the subsection where the Enigma ciphers were being broken.
Several ciphers had been broken at the beginning of 1940 as a result of information supplied by the Polish codebreakers. But by the spring of that year the Polish methods were no longer working, and Bletchley had been unable to make more than the occasional break into the German ciphers. The "Yellow" Enigma cipher used by the Germans in Norway had been relatively easy to crack, but the ciphers used elsewhere were proving difficult.
With the Germans expected to invade Belgium, the Netherlands and France, the race was on to break the "Red ", the most important Enigma cipher at the time. The Red was used by Luftwaffe officers liaising with the ground troops, so provided vital intelligence on German plans.
John Herivel, another of the young mathematics students recruited from Cambridge, had suggested that German operators using the Enigma machine might try to cut corners in a way that might help the codebreakers. The Enigma operators were told which rotors and settings to use each day; but once they had set up the machines they selected their own starting position for the rotors. They then sent that starting position as a three-letter indicator at the beginning of their first messages.
Herivel realised that a lazy operator would not move it much further away from where it had been the night before, and reasoned that if a number of operators behaved in the same way, the start positions would all cluster around the previous night's finishing position, reducing the number of possible start positions to a much smaller number.
The Hut 6 codebreakers looked out for clusters (known as Herivel's Tip), but none were found. Then, on May 10 1940, Germany invaded France. According to Herivel, Rees was working on his own on the night shift in the Machine Room, and noticed that among the many Enigma messages there were several that were very close together. So he tried out various possibilities, and as the day shift came in he finally managed to break into the Red.
Stuart Milner-Barry, the deputy head of Hut 6, later said: "I can remember most vividly the roars of excitement, the standing on chairs and the waving of order papers which greeted the first breaking of Red by hand in the middle of the Battle of France. This first break into the Red was the greatest event of all because it was not only, in effect, a new key, which is always exciting, but because we did not then know whether our number was up altogether or not."
It was one of the most decisive moments in the breaking of the Enigma ciphers, certainly of the Army and Luftwaffe ciphers. The Red would be the main staple for Bletchley and would be broken from then on continuously until virtually the end of the war. However, Rees himself was not sure that he deserved the credit for the breakthrough. In a document reproduced in John Herivel s book Herivelismus and the German Military Enigma (2008), he wrote: "I do not recollect being the person who was responsible for the first successful use of the Tip in breaking a day's key. In fact, my "Since this all happened 59 years ago, it is possible that my memory is at fault."
In late 1941 Rees was also involved in the vital break into the Enigma used by the German secret service, the Abwehr. MI5 had captured most of the Abwehr agents sent to Britain and was using them to feed false information back to the Germans.
But the communications between the German agent runners and their bosses were enciphered using a highly complex Enigma machine, so it was not clear if the Germans had been fooled by the deception.
Rees was seconded to the Enigma Research section run by Dillwyn ( "Dilly") Knox in late 1941, and a few months later they succeeded in breaking the Abwehr Enigma.
The Double Cross committee, which ran the captured German agents, used them to persuade Hitler that the D-Day landings would be south of Calais rather than in Normandy. Brigadier Bill Williams, Montgomery's chief intelligence officer, said that without the break into the Abwehr Enigma they could not have known the deception was working.
Rees subsequently moved to the Newmanry, where the Colossus computer was used to help to break the German high-level teleprinter ciphers. Max Newman, who had been Alan Turing's tutor at Cambridge, had devised the idea of using a computer to break the second row of wheels on the German SZ40 teleprinter cipher machine.
Colossus, the world's first working electronic computer, was built by Tommy Flowers, the chief engineer for the GPO, according to requirements laid down by Newman. The SZ40 ciphers, code-named "Tunny" by the codebreakers, provided the text of the conversations between Hitler and his generals in France, Italy and on the Eastern Front. They yielded a great deal of the intelligence that was needed to mount the D-Day landings and to defeat the Germans in Italy, France and Germany itself.
David Rees was born on May 29 1918 and educated at King Henry VIII Grammar School in Abergavenny and at Sidney Sussex College, Cambridge.
His wartime work with Colossus led to his recruitment by Max Newman after the war to join the Mathematics department at Manchester University, which was then at the forefront of the British development of computers. In 1949 he returned to Cambridge as a lecturer in Mathematics and became a Fellow of Downing College. Ten years later he was appointed Professor of Pure Mathematics at Exeter, where he remained for the rest of his career, serving as head of the Mathematics and Mathematical Sciences department for many years.
Rees"s main mathematical interests lay in highly complex fields of algebra known as semigroup theory and commutative algebra -- both of which have applications in computer science. Several algebraic concepts and theories in these fields are named after him.
Elected a Fellow of the Royal Society in 1968, Rees served as a member of its council from 1979 to 1981. In 1993 he won the Polya Prize of the London Mathematical Society.
In August 1998, to mark his 80th birthday, a conference on Commutative Algebra was held at Exeter.
In 1952 he married Joan Cushen, who, as Dr Joan Rees, would become a Senior Lecturer in Mathematics at Exeter. They had four daughters, of whom two are Mathematics professors at British universities.
Professor David Rees, born May 29 1918, died August 16 2013
20 Aug 2013 © Telegraph Group Limited