On the Usenet newsgroup comp.lang.c, I once saw a newbie ask how to find out whether a number is odd or even (in C, I mean). In C, this is delightfully simple: Just have a squint at the low-order bit; if that's turned "on", it's an odd number:
if ( n & 0x00000001 )
puts( "It's odd . . . DAMNED odd . . ." );
Well, some smartass offered the following hilarious solution (those who don't speak C can skip ahead over this typewriter font stuff; there's a plain English explanation afterwards):
int is_odd( int n )
{
unsigned long i;
for ( i = 0; i <= 4294967295; i += 2 )
if ( n == i )
return 0;
return 1;
}
Now, what that code does is it compares a number (n) to every even number that the computer can reasonably deal with: 4294967295 is the largest integer you can express in thirty-two bits. So in some cases, that code would make more than two billion comparisons before coming up with an answer. I thought converting 0xffffffff into decimal was a nice touch.
That's brute force, baby.