From Dirk J. Struick’s A Concise History of Mathematics (1967), quoted by Shallit:
There exists a widely quoted story about Diderot and Euler according to which Euler, in a public debate in St. Petersburg, succeeded in embarrassing the freethinking Diderot by claiming to possess an algebraic demonstration of the existence of God: “Sir, (a+b^n)/n = x; hence God exists, answer please!” This is a good example of a bad historical anecdote, since the value of an anecdote about an historical person lies in its faculty to illustrate certain aspects of his character; this particular anecdote serves to obscure both the character of Diderot and of Euler, Diderot knew his mathematics and had written on involutes and probability, and no reason exists to think that the thoughtful Euler would have behaved in the asinine way indicated. The story seems to have been made up by the English mathematician De Morgan (1806-1871). See L. G. Krakeur and R. L. Krueger, Isis, Vol. 31 (1940), pp. 431-32; also Vol. 33 (1941), pp. 219-31. It is true that there was in the eighteenth century occasional talk about the probability of an algebraic demonstration of the existence of God; Maupertuis indulged in one, see Voltaire’s Diatribe, Oeuvres, Vol. 41 (1821 ed.), pp. 19, 30. See also B. Brown, Amer. Math. Monthly, Vol. 49 (1944).
Krakeur and Krueger state that his investigations into mathematics “dominated Diderot’s youthful activities and represent an important phase of his universal interests.” They speculate that a lack of mathematical background among scholars who studied the man impaired those scholars’ ability to address this part of Diderot’s life.