Fish tank with Puck the Fish Fish tank with Puck the Fish Water on the floor spelling Fish
 

Spam

August 9th, 2005

Well, they found me. I knew it was only a matter of time. It happens to every blog. Comment spam, and a lot of it. But nobody told me it would be like this! I got about 200 messages an hour. I mean, the attention is flattering, but still, my goodness! Let’s see what we can do about that.

(If you hate math and all you care about is how to post a comment, go to The Punchline)

π

This fish was a math major in college, and mathematics is still fascinating. It’s haunted, haunted by numbers! Particular numbers appear over and over in unexpected places, much like Spam, the topic of this post. And the creepiest number is π. I’m going to calculate π, and I need your help! But we have to start at the other end, with prime numbers.

Relatively prime

Every number has a prime factorization. But we can also talk about numbers being relatively prime, or coprime. Two numbers are relatively prime if they don’t share any factors. If two numbers share a factor, then they also share a prime factor, by the fundamental theorem of arithmetic. Yeah, simple stuff. I saw you scan ahead; you know this already.

Now if we pick two random positive integers, uhh, we’ll call them "A" and "B". There. What’s the probability that A and B are relatively prime? Well, two numbers are relatively prime if they don’t share any prime factors – that is, if they’re not both divisible by some prime. What’s the first prime? Let me check my list of primes…oh, 2! For two random numbers, what’s the probability that A and B are not BOTH divisible by 2? Well, that’s, uhm, multiply half by half, subtract from one…75%. . Yeah.

What’s the probability that they’re not both divisible by 3? Well, every third number is divisible by 3, so A and B would both have to be a "third number" to be divisible by 3. The chance of that happening is , so the chance of that NOT happening is one minus that, uhm, .

Oh, I get it. The probability that they’re not both divisible by 5 is . And so on. Ok, so the probability that A and B are not both divisible by a prime number P is .

Multiplying it out

Now what? Well, for every prime P, we know that it does not divide both A and B with likelihood . How about for all primes? If no prime divides both A and B, then A and B are relatively prime! When you want to know if this happens AND that happens, you multiply their probabilities. So multiply the probabilities for each prime, like this:

Oh, make that fancy math-speak.

Uh…ok, what’s that? It’s more than I’m going to calculate here, that’s for sure. But someone else already did. It’s (drumroll) .

Whoa, where’d that come from? What on earth could the ratio of circumference to diameter yadda yadda have to do with integers being relatively prime? Nevertheless, there it is.

So what?

So we started with prime numbers and ended with pi. So what? Well, here’s how it’s going to work. You’re going to give me two big random numbers, and I’m going to record them and figure out if they’re relatively prime or not. Then I’ll figure out the percentage of pairs that were prime, and flip it over and multiply by six and take the square root, and we should get π. Isn’t this cool? We can calculate π based solely on the random numbers you indiscriminately smash on your keyboards.

But I called this post "Spam." What for? Well, as Andrew Wooster points out, stopping spam can be as easy as adding an extra field to the comment form. Have you guessed the punchline yet?

The Punchline

You will give me your random keypresses! (The power of mathematics compels you!) There’s a new box in the comment form, with two fields in it. When you want to post a comment, type two big random positive integers into it. That’s right, just bang whatever on the number keys. The only rule is that the numbers have to be positive and from 11 to 35 digits. If you don’t do this, you’ll get an error message and your comment will be refused. If you do, your comment will be posted and you’ll find out what π is so far. This will happen for every post.

And if you just want to donate your keyboard banging without commenting, there’s a similar box in the upper right of every page. Put your numbers in there and click the button. You’ll be taken right where you are, but you’ll know what π is.

 

The Internet!

π = 3.2828694983

This is a pretty cool idea. Too bad it’s not generally useful.

Way to have fun with the spam… Why not find a way to have the spam comments contribute to the calculation too? Convert their posts to numbers and use them for Knowledge…

It’s a helluva lot better than looking at heavilly distorted images, squintingly trying to figure out what strange symbols that machine is trying to make you copy into plaintext.

I’m just leaving my numbers here.

Is it wrong to wish that you had a graph of the current calculated values vs. the number of entries? (I want to see it asymptotically approach the value dangit!)

Good idea, Daniel. I’ll see if I can make a graph.

This is a really neat idea. Probably not the fastest way to calculate Pi, but it should be an interesting experiment. I’m looking forward to seeing how it turns out.

Rura

Very cool, can’t wait to see how random our numbers really are.

Josh

And so much fun! Fantastic. Looking forward to the graph… ;-)

WordPress should now forward the fact that you entered numbers to the comments page, so that you can see the current pi estimate.

Anonymous

Typing Numbers!

Remember, you can always just type as many numbers as you like in the box in the upper right of the page. You don’t have to post a comment.

I am generally against having the user type information in, which is not used for identification, to allow commenting. This is, however, much better than any captcha (or whatever they’re called). And I had to post a comment to see what Ï€ was so far.

Hrm, maybe I should read the full post before letting out hot air.

OMG I so love mathematics too! And I really, really love number theory, so that was a really, really cool explanation. (I just recently got my B.S. in mathematics as well as geology.)

OMG OMG numbers!

(And it’s so fun to “indiscriminately mash out” numbers on my keypad too for your comments section. Way cool!)

– Simone

Anonymous

Hello where’s my pie?

joshua

see what happens

Comment Spam is the dumb

In general, I don’t like the ‘catchpa’ idea for preventing comment spam, but I have to admit that this particular…

Math

You are really, really tempting me to write a program to get your Ï€ equal to 2.71828183…..

Finally a spam-blocking solution people can enjoy using. The tab indexes need a bit of tweaking though.

Thomas

BTW, when I use TAB to get from field to field in the submit comment form, it goes from the name box to the email box to the website box to the comment box to the Submit Comment button…. and then I had to tab through every link in the body of the post and the previous comments before it finally returned to the Very Large Number boxes. Perhaps the form can be tweaked so that the VLN boxes are in the tab order after the Website box? (Using Firefox 1.0.6 on WinXP).

Anonymous
Andrew

This is so fantastically dorky. I love it!

Thanks to everyone who pointed out the tab order problem. That should be fixed now.

Ryan

This is neat. I just want to see what π is at. :)

Spam

Spam

Brilliant. This beats my previous attempt of asking the user if they were a squirrel monkey. Which confused some users as well as the actually spammers, and insulted squirrel monkeys all over.

pmazer

I just want to see how this works

I’m going to use my cell and home phone numbers.

Narcoleptic Electron

This is a great idea.

To take it further: you could use some sort of algorithm to generate two viable numbers using a regular comment. (For example, you could use the date and time of the posting as a random number seed.)

That way you could literally use comments without requiring the users to actually type the numbers.

And I agree with another poster above: I would love to see a graph!

Narcoleptic Electron

About my previous comment: now that I’ve submitted a comment, I realize that typing the numbers is the whole point (to prevent comment spam)… so never mind.

I hate to add to the comments just to see what pi is up to, but I’m going to anyway. This is an amazing idea, and a great way to stop comment spammers. Although I found that just changing the name of the coment script worked pretty well.

monkey guts

hey

Wow, this looks interesting. Gotta give it a shot.

Jonathan

This is totally awesome! :)

Dan V. P. Christiansen

Wow, you already got the first digit, only n – 1 to go. My sincere congratulations.

Anonymous

Here are some more numbers

Cool… probably the most amusing spam related thing I’ve seen.

I’ll be interested to see how that works out. Particularly how random the numbers we enter actually are. I suspect that due to the layout of a decimal keypad this might be a bit skewed.

(Unfortunately the field at the top of the page seems to need a really wide browser window to be visible.)

Gavin Sharp

Great idea

Good cheese to you!

Hooray for pi.

Brian

You’re way, way off, man. I think it’s closer to around 3.608.

John Walker, proprietor of Fourmilab, provides Feedback Form similar to this which requires the would-be submitter to solve a simple linear equation in order to post a comment. This not only eliminates comment spam, but is a hurdle to those who can’t do simple math.

Here’s the link to the page – he provides the perl source for the cgi:

http://fourmilab.ch/webtools/feedbackform/

Cheers!

Hehe, this is a great idea! Although I notice a bunch of comments that were posted for the express purpose of seeing what pi was up to so far…

One thing I noticed was the source of your page is HORRENDOUS! I wrote my own HTML syntax colorizer that hooks into Safari to colorize its View Source window – I’ve never had it take longer than about half a second. When I tried to view the source of this page, it took 33 seconds!

Outstanding!

Jason

Enjoy the numbers!

A Few Upgrades

After having to delete a few hundred spam comments from my weblog this week, I finally admitted that my blacklist wasn’t stopping any spam. Apparently domains have gotten too cheap for blacklists to be a viable deterrent anymore.
So, today I up…

This is a very good idea. Keeping the comment spammers away and estimating the value of Pi at the same time!!
I’m just leaving this to help you figure out the value of Pi. :)

The onion is the ointment is that the numbers may not be as random as you might suppose. I’m betting that the numbers produced by two-handed people banging on querty keyboards have some measurable characteristics. We’re likely to see many runs of consecutive digits and an alternation between hands. In information theoretic terms, the numbers people type don’t have as much entropy as truly random numbers of the same length. (Or at least, that’s my wager.)

Given poorly distributed input data, will the answer still converge on pi?

Once you have a lot of input collected, I’d love to see the collected numbers. It might be fun to run them through Knuth’s tests of randomness.

mare

If you need random numbers you could also just google some random text from the Interweb and transform it into numbers by getting the ASCII value of the individual characters. But it won’t defeat Spam. And it’s not as cool.

bw

delicious.

Curious

Just curious.

Will you be posting your calculated pi as the numbers roll in?

Hey, cute idea! I use a simple Q&A field to block spam on my blog, but I was just a physics major.

One thing: it would be nice if the size of the number input field was restricted to stop you from typing numbers that are too long. Then people could mash keys without worrying about the length.

Mmmm… Pi!

jacob

Pi!

zac

tee hee

WombatPredator

This is fascinatingly geeky. Sign me up.

And I thought high school math was never going to be useful…

Niteflite

I think that you shouldn’t have published your algorithm before soliciting random numbers. In particular, you shouldn’t have said that you’re looking for primes.

I think that far too many people will conciously avoid entering even numbers and that this will skew the probabilities to such a degree that the constant in your formula is somewhat greater than “6″. (It wouldn’t be exactly double this because I expect that there will be some truly random numbers entered which are even, just with a frequency of *much* less than 0.5).

Yo! Come see my online casino! Get yet hot grits ‘ere!

Fight SPAM and Do Math All at Once

This is interesting

YIPPEE! That’s great! Are you going to publish the results?

nsf

Way cool idea. very novel!

Great idea

Interesting that on line casino dot com made it to post. They probably have a few numeracy skills there somewhere…

Absoulutely brilliant.

What is pi?

Anonymous

wtf

Anonymous

OK…let’s see it…

anonymous

this is awesome

argod

hope I win!

Whats 3.14 and eatible?
(IF you don’t get that, you fail the nerd test totally…)

Bobby

I’m pretty sure there’s a 2 in there somewhere.

Tom

Serve me up some pi. I like cherry.

John C. Randolph

Peter, do your logs show the comment spam coming from a narrow range of IP numbers, or does it seem to be coming from a zombie net?

-jcr

Anonymous

“Pi is exactly 3!” — Professor Frink.

Dylan Moreland

This is excellent!

FadedSun

w0rd!

Anonymous

What about e?

cute.

Have you considered calculating the other Zeta values at the same time? If I recall correctly, you can use triples to calculate 1/Zeta(3). Also, it is sufficient to ask for a single number and test relative primality with the previous |n| numbers to determine the probability. You can use the previous |(n-1)n/2| pairs to calculate 1/Zeta(3) and possibly O(n^(k-1)) k-tuples to calculate 1/Zeta(k). Getting the values of Zeta(2 j) will help to make the pi calculation more accurate. Of course, you probably wouldn’t want to use O(n^(k-1)) k-tuples with the new value, but some subset.

Keep up the good work.

Anonymous

You say numbers must be from 11 to 35 digits long, but I get “Your number was too small” when I enter 10000000000.

Bruno

Just testing ;-)

diskgrinder

how big is my slice of pie?

interstingly enough: the connection between pie and probability made it into the latest episode of numb3rs ;-)

Anonymous

Hi.

Influence

Interesting stuff …

pi rulez.

This was brilliantly funny! I liked it!

This is a nifty idea!

kolis

Hehe, great initiative!!

qwerty

cool stuff!

asjashjashjas

The king of beligium of the 1830s was a paedophile, abd leopold, who ran it in the 1890s, killed more people than lenin and pol pot tiogether

Tyler

Just typing in some numbers.

Durden

Spam to see how good pi is yet

oooooooohhh…
spam pi!!!

El Gato

My contribution to a greater pi. Interesting idea.

ns

novel idea.

jacob

Just adding some numbers.

oli

testing numbers.. (i guess this will end up getting you more spam in the long run)

Monkey see, monkey do.

Adam

Cool.

malson

Wow…pretty cool idea and definitely beats the random “word images” that are commonly used.

Interesting how many people first missed the “hidden” purpose of entering the numbers. I came here from a link about captcha’s, though, so maybe the perspective had a big impact on what people took away from reading your article. If they came from a math link or search, perhaps they were more likely to miss or ignore the parts of the article talking about the spam comments?

Anonymous

OK, but how long before it gets anywhere close to the value for pi?

Matt Brandt

So, is this thing converging yet?

Durden

not even close by now. Seems to go more towards 3.3 or something.

Hi,
we are testing a new free form-protection service (http://www.cerospam.com.ar), for blogs and for any kind of web site. It is easy to setup each form with this system, and it is very useful for protecting comment forms from spammers.
It is based on captcha method. Until now it seems to work fine. No matter what kind of blog software you are using, this is not a plugin.
Please, test it and do not hesitate to send us your comments!
Thank you.

J Osborne

Hi, someone said I could get some pie here?

banana cream

my lawyer will be sending you a cease-and-desist notice…

Paul S

I will give you my large random #s …

test

so cool

Nick

Pi!

Cool.
Is there anyway you can track the changes in pi with each set of numbers added? A kind of “history of pi” of sorts!

[...] h in Personal, Web If you don’t like maths, don’t click this link! Riciulous Fish – Pi Interesting attempt to stop spam by [...]

Anonymous

anus

Now I gotta see..

my turn…

Joshua

Testing… 1… 2… 7…….!!!!!

He, can I get your number?

Maths Is Fun!

krassi_holmz

Hi. That’s great idea!
But i don’t think you’ll get many numbers of Pi soon..
Using Mathemaica, I got that you’ll need > million tests for 3 demical places of pi.

Anonymous

nice. wish i understood it

test

test

HerrWurst

very interesting indeed

boosh

Neat.

boosh

Neat.

…Love this idea!

Anonymous

testing

Anonymous

a comment

Derek

brilliant! I gotta see!

Anonymous

pi

Steve Hawking

I like cheese.

Pi Napple

I agree. Cheese is tasty.

Anonymous

spamity spam.

Anonymous

what

Anonymous

Heh

Anonymous

here are my numbeers

Anonymous

asdf

Anonymous

asdf

I guess, then, you encourage any kind of comment that helps you calculate π, without giving unwanted outside links ;-)

What about the “website” field?

Anonymous

asdf

I Just *have to* test this :-)

Anonymous

Nice idea

Anonymous

Cool.

Jon

Hmm

Got to help find this pie…

Steve Ryan

Hello

Rahul

I want to know pi too!

Gsu

[message here]

spam for pi
spam for pi

will well

please skip the spam and serve the pi

ian

That’s pretty cute. But– uppercase Pi had already snuck in, when you were taking the product! It can’t be stopped!

Neat stuff.

Anonymous

cool

Anonymous

Will the numbers actually be random?

yen

Great, but doesn’t square rooting give you an error?

Anonymous

ah

Anonymous

show me pi

Anonymous

i used all ones, i win.

Anonymous

ssfsdfsdf

Anonymous

a

[...] like the Web Developer Toolbar, it’s essential for speedy web development. Brian – Best Comment Spam Fighting System Ever. – Found the blog through The Treacherous Optimization article, an ex [...]

The power of irrational numbers compels YOU

GiGi

Bonne idée, mon petit poisson!

uuuuutube

wheee!!!!

I have to say that this is a great alternative to the regular old captcha’s that are around.

Well that was the last thing I needed on a Saturday morning!

hbooth

This is a cool idea, but it may not approximate pi if the numbers users type in are not random. I could type in a pair of numbers that made the result go the wrong way and then do that over and over. Or figure out whether it needs more relatively prime or not relatively prime pairs to make it converge and then choose numbers accordingly.

Stoyan

What’s my pi!?! :)

how do i not shoot the puppy?

delta

does it come with apple inside?

Anonymous

have to try it

Anonymous

More Spam

Anonymous

Test.

tef

I am writing this comment to see what pi is at the moment

Argh!

So, what’s pi up to?

anon

asdf

anon

asdf

[...] ting. I’m going to employ the Did you pass math? plugin. Not as fascinating as the system over on ridiculousfish.com, but I like it none the less. I figure that if people today can’t ad [...]

Scott W. Smith

A great way to calc pi – interested to see how you do it

I know this is sad, but I’m just watching..

Want to see pi!

steve

it’s more fun to compute

James

aoeu

(Had to give Dvorak some representation in the useless typing world.)

Did you ever implement that graph? I had the same idea. The graph should have a horizontal line through it indicating the actual value of pi, to better see how close we’re getting.

Next project: write a program to submit lots of large numbers to this weblog, but instead of random numbers, pick pairs designed to steer the cumulative result closer to pi.

Yeah i gotta see this.

inter

interesting

ugly

Ibaun

just want to see this :)

1

test :D

Just helping the cause…

yeah

glad to see someone that loves math enough to think up ideas such as this

Althoug yyour anti-spam technique is extra cool, I suggest you take a look at Spam-Karma 2 wordpress plugin.
does a greatwork for me.

Sumant Manne

I

Me

I just want to know the value of π.

Anonymous

ok

[...] don’t have to do any actual mathematics. I’m not going to spoil the surprise: head on over and take a [...]

debashis

That’s cool

2349723498723948723948723948723948

Anonymous

What is pi?

Interesting captcha I must say….

Jim

Was that large enough?

that’s so smart ! well done !

Kim

great idea

The skin of your blog simply rocks.

ciphex

The coolest thing I have seen this month. No shit.

If I was a woman I would have sex with you for this alone.

Anonymous

a

Solis

The only problem is, won’t random keyboard spamming eventually just follow a formula and as such not be random? Will that even really matter?

Joe

I just had to test this out.

Anonymous

?

spam?

spamming you

bl

test

bob dole!

Flaubert P. Rogers

Pi isn’t a number, it’s a foodstuff.

asdf

Anonymous

789879789

Jon

Mmmm…..pi

Hate to tell you this Ciphex, but if you were a woman you’d probably just think he was a big geek. :-)

Gilles de la T.

Women prefer BIG geeks… :-)

Nice site man! Good resources here, I will bookmark!

Anonymous

hi pi

anon

pi-tacular

anonymouse

squeak!

Your technique will never calculate pi. The problem is that A and B are constrained to be between 11 and 35 digits long. So the probability that an arbitrary prime p doesn’t divide either is not exactly (p^2-1)/p^2.

In fact, trivially no prime with 36 or more digits will ever divide either A or B, so once you get that far in the infinite product, all the probabilities become exactly 1.0 instead of (1-1/p^2). This error alone will cause you to overestimate the value of pi by some amount, but it’s not the only error factor introduced by the range restriction on A and B.

David S

Pi?

Nice.

This is cooler than that Heinekin commercial with Darth Heinous in it

Anonymous

hi

Thats so cool… better than the annoying captchas. pi rocks!

I want to see what pi is.

Not as cool as my site ;¬) but worth a try anyway.

Does this count as spam ???

Adam

Michael Brundage has already said it, but you are not going to get to pi this way.
I suggest you treat the two numbers as the decimal part of cartesian co-ordinates, and check if the magnitude of the vector is less than one. If the numbers were truly random the ratio would tend to pi/4. It has the advantage you wouldn’t need to stop people entering arbitrarily many digits, if they felt like it, and the truncation would not cause a massive systematic bias like your current method does.

What’s pi up to…

just testing.. ignore.. or delete even..

decembrino

Very good idea.

Seriously – it made me thinking

decembrino

Very good idea.

Seriously – it made me thinking

Daniel

Very nice. One of the more creative things i’ve seen on the web recently.

G

Dunno if someone else has suggested this, but what about feeding the raw numbers entered into a PRNG. It won’t increase the resulting entropy, but it will reduce the influence of some of the effects alluded to by some commenters – consecutive keys, hand alternation, avoidance of even numbers, etc. It might help avoid deliberate attempts to sabotage the eventual outcome.

I am compelled, by the beauty of 6/pi^2 … extraordinary!

google rang.tong (empty of self) and shen.tong (empty of other) … I argue that those who claim rang.tong and deny shen.tong do so because they don’t truly grasp the former; those who grasp the former inexorably go on to the latter … elegance!

harsha

nice idea

Yamada

Well, if I have to comment, I might as well say something novel.

Here’s a palindromic haiku I wrote:

Solo gig on tub
Flesh — I saw Mimi wash self
But no gigolos.

Sid

Test comment

me

alatest

undefined

That’s so cool!

Gordie

I’m a big fan of random features of pi (and e for that matter).

After I read this, I actually wrote a program using Bignums that randomly generated large numbers and checked to see if they were relatively prime, and left it running a few days. It was damn close to 6/pi^2.

fdssfs

Anonymous

pi

hi

ok

asdsa

test

Ubervan

That was a load to read just to be told to leave 2 big numbers.

Anonymous

this rocks

Nonsens, everybody knows that pi=355/113. So how can it be that strange calculation of yours?

Lenny

Just doing my part in the calculation of pi

Henk

yes

Anonymous

Actually, function templates in C++ are not inlined – just because they are declared in header files. To be an inlined function, a function template still needs to be declared with the “inline” keyword – just like any other function.