LONDON , England ( CNN ) -- British Prime Minister Gordon Brown has issued a posthumous apology for the `` appalling '' treatment of Alan Turing , the British code-breaker who was chemically castrated for being gay . A portrait of Alan Turing is currently on display at the National Portrait Gallery 's `` Gay Icons '' exhibition . The apology came after more than 30,000 people signed an online petition on the UK Government Web site calling for the government to recognize the `` tragic consequences of prejudice that ended this man 's life and career . '' Turing was just 41 years old when he committed suicide , two years after undergoing a court-ordered chemical castration . He had been found guilty of gross indecency for having a homosexual relationship . The punishment in 1952 was either a prison sentence or chemical castration . Turing chose the latter . In a statement on the British Government Web site , Prime Minister Gordon Brown acknowledged Turing 's `` outstanding '' contribution during World War II . `` He truly was one of those individuals we can point to whose unique contribution helped to turn the tide of war , '' he wrote , adding , `` The debt of gratitude he is owed makes it all the more horrifying , therefore , that he was treated so inhumanely . '' Turing is considered one of Britain 's greatest mathematicians , a genius who is credited with inventing the Bombe , a code-breaking machine that deciphered messages encoded by German Enigma machines during World War II . He went on to develop the Turing machine , a theory that automatic computation can not solve all mathematical problems , which is considered the basis of modern computing . Last month , the curious lack of public recognition for Turing 's contribution to the war effort and computing in general motivated computer programmer John Graham-Cumming to campaign on his behalf . The author of the `` Geek Atlas , '' a travel guide for technology enthusiasts , started an online petition , and soon attracted high-profile signatories including scientist Richard Dawkins , actor Stephen Fry , author Ian McEwan and philosopher A.C. Grayling . `` I was surprised by both the number of people who signed and the fast response from the government , '' Graham-Cumming told CNN . He said the Prime Minister had called him personally to relay news of the apology . Stories about calls for a British apology were carried in newspapers in France , Switzerland , Spain , Austria , Portugal Poland and the Czech Republic . Supporters set up an international petition which attracted more than 10,000 signatures .
Online petition calling for apology for Alan Turing elicits response from UK PM . Gordon Brown issues statement apologizing for his `` appalling '' treatment . Turing committed suicide two years after undergoing chemical castration . Best known for decoding messages from German Enigma machines in WWII .