Is there a prime number whose…

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

Yes!

like another prime number?

Yes!

like a prime number of giraffes?

YES!

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.

Leave a Reply

Your email address will not be published. Required fields are marked *