Is there a prime number whose…

Is there a prime number whose binary representation looks like a giraffe?


like another prime number?


like a prime number of giraffes?


like Squidward Tentacles?

Heck Yeah!

You’ve probably understood the mechanism by now. Converting a binary image into a number, its nearest upper prime generally only differ in the lesser significant bits, hence most of the image pattern stays the same. So finding a prime number whose binary representation looks like a specific image is relatively easy. I say relatively, because in a computer sens it is quite really complex.

I just wrote a program to do just that. It is written in C and uses GMP. It is around 1k SLOC. It could probably have been much shorter, and even less so in another language. But I wanted something that went a little further than just of simple proof of concept.

I must admit, it’s pretty useless. But still there it is. And there is still much room for improvement. So patches are welcome on GitHub.

Why code In C anymore?


“Also, because it makes you a Real Man™, with steel wool-like hair on your chest and a distant gaze, as though contemplating the segfault that got away; UNIX beard moving gently in the harsh nautical wind that is ever present near C programmers.

The reason C is pronounced “sea” is because it refers to the sea of tears of quiche eating inferior programers who got too close to a programming language for Real Men™, and got burned, swearing to never leave the comfort of the namby pamby interpreted language that nutured them as wee latte-drinking babes with scarves.” [BobTheSCV (Reddit)]