
A prime number whose binary representation looks like a giraffe - svenfaw
https://www.reddit.com/r/math/comments/7qpfls/does_there_exist_a_prime_number_whose/
======
theaeolist
The last line of the picture contains some 'noise':

0000000000000000000000000000000000000000000000000001000101101001

So the idea is that you produce any 63x64 binary image then you find a number
up to 2^64 so that added to the number represented by the first image gives a
prime. It's not exactly amazing, but clever enough.

~~~
szemet
Or you can move the image on canvases of different size until you find a
position/size where it is prime.

Several other methods can work... Primes are not rare at all - average prime
gaps are fairly small in that domain...

~~~
krisives
Isn't the largest gap for any prime sqrt(n) ?

~~~
phkahler
not even close. the average gap is closer to log(n).

~~~
qmalzp
The average gap is log(n), but the maximal gap is not well understood.

According to
[https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_conjecture](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_conjecture),
current results are

Unconditional: n^0.525

Conditional on RH: log(n)*sqrt(n)

Conjecturally: log(n)^2

~~~
chx
> It is still probably true that for every constant {\displaystyle c>2} c>2,
> there is a constant {\displaystyle d>0} d>0 such that there is a prime
> between {\displaystyle x} x and {\displaystyle x+d(\log x)^{c}}
> {\displaystyle x+d(\log x)^{c}}

That's quite fascinating.

------
reificator
I think the more interesting way to do this would be to create a border that's
roughly circular to frame the giraffe, and fill that border with noise. Then
do the incrementing thing, and your 12 or so bits of noise at the end will
blend in better, making it harder for the average person to reverse engineer.

I'm imaging something like this, but with a giraffe instead:
[https://6d4be195623157e28848-7697ece4918e0a73861de0eb37d0896...](https://6d4be195623157e28848-7697ece4918e0a73861de0eb37d08968.ssl.cf1.rackcdn.com/873_200w.jpg)

 _(Sorry for unreadable CDN link)_

~~~
mkl
I had the same sort of idea, and just implemented it in Python using gmpy2 for
the primality check. Here's a prime smiley face:

    
    
      111010101111001000110101111111001001000010000
      000000000000000000000000000000000000000000001
      000000000000000001110111111100000000000000001
      100000000000011110000000000011010000000000001
      000000000011100000000000000000011100000000000
      100000000100000000000000000000000011000000001
      100000011000000000000000000000000000100000001
      100000110000000001000000001000000000011000001
      100000100000000001000000001000000000001100000
      000001000000000001000000001000000000000100001
      100010000000000001000000001000000000000010000
      000010000000000001000000001000000000000010001
      000010000000000001000000001000000000000010000
      000010000000000000000000000000000000000010000
      100010000001100000000000000000001100000010001
      000001000000110000000000000000011000000100000
      000000100000011000000000000000110000001100001
      100000110000001111000000000111100000011000000
      000000011000000001111111111100000000100000000
      100000000100000000000000000000000011000000001
      000000000011100000000000000000011100000000000
      100000000000011110000000000011010000000000000
      100000000000000001110111111100000000000000000
      100000000000000000000000000000000000000000001
      111011110010001011101100010110111111110011001
    

As a number, it's

    
    
      418286130038247526051590581692998429049634527936177232676862400134230223310124567196900044669909574838414882468188159808593146618824409867113710174334769625185535031892647808338085451521099179358299885075661065903947563499117521951858387121272237585876050870984471996640946451287415573046990997289875221396633775785411121263373993999302553.
    

This took 487 random border attempts to find, which seems pretty small!

Note that efficient primality tests are probabilistic, so there's a small
chance this isn't actually prime. I expect it's the same with the giraffe one
in the link.

Edit: Here's the code (improved a bit over what made the picture above):
[https://gitlab.com/snippets/1694391](https://gitlab.com/snippets/1694391)

~~~
Smaug123
It is provably prime; I got Mathematica to generate a certificate for it in
about five minutes using `PrimeQCertificate`.

~~~
phkahler
Sometimes its a good idea to use a faster probable prime test when searching,
and then use a slower test to verify the result. As has been done here.

~~~
SAI_Peregrinus
Lenstra and Pomerace's variant of the AKS test is O(log(n)^6), and
deterministic. So polynomial, and not a huge exponent. Still not as fast as
the probabilistic algorithms, but not as slow as pre-AKS methods.

~~~
YomiK
"not as slow as pre-AKS methods." only in terms of provable asymptotic bounds.
It's _much_ slower than APR-CL and ECPP, both of which existed before AKS, and
are the methods used daily.

------
userbinator
Great, another great demonstration of the fundamental principles of digital
computing - representation and interpretation of data. It's been my experience
teaching CS courses that many students, despite being taught bits and bytes
and binary and ASCII and so forth, don't really "get it" until they see things
like this.

This particular one only looks like a giraffe when it's interpreted as a 1bpp
big-endian bitmap, but you could probably do the same with a colour (24bpp, in
whatever order you wish) photo.

Here's another fun idea: write a short program that checks if a file is a
prime number. Now you can get into the principles of CRCs, RS, and other
error-correction codes...

~~~
qualitytime
"write a short program that checks if a file is a prime number."

What do you mean? I tried googling but failed.

~~~
colejohnson66
Hint: Interpret the file’s bits as a single number

~~~
qualitytime
Thanks for the clarification.

------
amelius
Here's another challenge: find a number whose binary representation looks like
Mickey mouse, and find the index where it occurs in the binary representation
of pi. Bonus: that index should have a binary representation that looks like a
copyright symbol.

~~~
rtkwe
We don't have the digits of pi for the second part. We only have
22,459,157,718,361 digits of pi which is only ~45 bits not enough to create
the image with bits left over for moving it around in pi.

~~~
selestify
How is that only 45 bits?

~~~
rtkwe
Cause that's how the math works. log_2(22,459,157,718,361) ~= 44.35. Powers of
two get big really really fast after all.

[https://www.wolframalpha.com/input/?i=22,459,157,718,361+to+...](https://www.wolframalpha.com/input/?i=22,459,157,718,361+to+binary)

~~~
plafl
Shouldn't it be log_2(10^22,459,157,718,361)?

~~~
daveFNbuck
That answers the question of how many bits of pi we know. If you want to be
able to take an arbitrary n-bit string and find its position in a set of n-bit
strings, you need to have something like 2^n strings in your set.

So to find the number of bits you can support for an algorithm like this,
taking the log of the number of digits of pi we know gives you a rough
estimate.

------
xaedes
Found the link in the comments to the "Walk made with the first million digits
in prime numbers" very interesting!

[https://www.reddit.com/r/dataisbeautiful/comments/79hads/wal...](https://www.reddit.com/r/dataisbeautiful/comments/79hads/walk_made_with_the_first_million_digits_in_prime/)

------
jamessb
Previously on HN, someone posted the The Corpus Christi Prime blog post [1],
which was inspired by the Numerphile Trinity Hall Prime video [2].

See also Zachary Abel's Prime Portraits article [3].

[1]:
[https://news.ycombinator.com/item?id=15208317](https://news.ycombinator.com/item?id=15208317)

[2]:
[https://www.youtube.com/watch?v=fQQ8IiTWHhg](https://www.youtube.com/watch?v=fQQ8IiTWHhg)

[3]:
[http://archive.bridgesmathart.org/2016/bridges2016-359.pdf](http://archive.bridgesmathart.org/2016/bridges2016-359.pdf)

~~~
iClaudiusX
See also Tupper's Self-Referential Formula [0] and the Numberphile explanation
[1] for generating bitmap plots of itself.

[0]: [http://mathworld.wolfram.com/TuppersSelf-
ReferentialFormula....](http://mathworld.wolfram.com/TuppersSelf-
ReferentialFormula.html)

[1]:
[https://www.youtube.com/watch?v=_s5RFgd59ao](https://www.youtube.com/watch?v=_s5RFgd59ao)

------
msuvakov
Cool but old. It can be done in any number base, e.g. in decimal:
[https://www.youtube.com/watch?v=fQQ8IiTWHhg](https://www.youtube.com/watch?v=fQQ8IiTWHhg)

------
js8
I think it would look much better had he put a frame around it with binary
ones. It would not only hint about how to decode it, but it would also make it
more likely to be prime (ending with huge number of 1s) and hide the ugly
noise.

I would also like to conjecture that there is infinitely many primes that look
like a giraffe in binary, so it's nothing that unusual.

------
RiderOfGiraffes
I guess I should comment here, but I don't have much to add. Most of the
questions that arise naturally about how this was done, and about primes in
general, have already been asked and answered.

Still, given my username I should add something ...

So if the size was prime x prime then the fact that the number of bits is a
semi-prime tells you the size of the image, even if all you have is a stream
of digits. Then the "noise" at the end will tell you what the least
significant bits are, and hence you get an image without very much ambiguity.

Just thought I'd mention that.

------
tzahola
Neat. Reminds me of illegal primes:
[https://en.m.wikipedia.org/wiki/Illegal_prime](https://en.m.wikipedia.org/wiki/Illegal_prime)

~~~
sigotirandolas
It’s pretty much the same thing - take some arbitrary data, and add some bits
so that the result is prime. Not surprising from a mathematical point of view
since primes are very common, but it’s a fun thing to see.

~~~
bringtheaction
> primes are very common

Isn't it thought that they get more and more rare the further you go away from
zero in the positive direction?

By the way I just realized why no negative numbers are prime and that's
because -1 is a factor in all of them. Quite obvious but I just never thought
about it before.

~~~
mkl
-1 is not a prime, so that doesn't work. The actual reason is a little more boring - negative numbers are not prime by the definition of a prime number: "a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers" (Wikipedia).

~~~
posterboy
There's another definition, that doesn't have to exclude the one explicitly. I
think it's a natural number not divisible by any natural number smaller than
itself.

~~~
tzahola
*other than one

~~~
posterboy
damn what was it though ... can't remember where I read it.

------
raverbashing
Seems like an idea for a (lighter) proof of work, find a prime number in a
certain format (and the harder it is, the least noise it should have)

------
krylon
Did somebody stumble upon this by accident, or did they deliberately look for
a prime number and play with the layout until they saw a picture?

Either way, this is really cool.

~~~
mkl
They made/got the picture, converted it to a number (by interpreting it as
binary), then incremented the number until they found the next prime. The
incrementing is what made the "noise" in the bottom right.

~~~
krylon
Thanks for explanation. It does take away the magic, though.

It's still way cool, but how much cooler woulc it have been if a mathematician
had stumbled upon this by accident...

------
DoreenMichele
In my mind, math + giraffes =

[https://news.ycombinator.com/user?id=RiderOfGiraffes](https://news.ycombinator.com/user?id=RiderOfGiraffes)

There shouldn't be two answers for that equation. That is just too weird of a
coincidence.

------
ggambetta
Mods, please add ["Contact" (the novel, not the movie) spoiler alert] to the
title.

