TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Primg – Generate prime numbers whose binary representation looks like any image

110 pointsby geonnaveover 7 years ago

16 comments

shabdaover 7 years ago
Here is my Python implementation: <a href="https:&#x2F;&#x2F;github.com&#x2F;shabda&#x2F;experiments&#x2F;tree&#x2F;master&#x2F;prime_dinos" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shabda&#x2F;experiments&#x2F;tree&#x2F;master&#x2F;prime_dino...</a><p>I put up a show HN, but no one liked it :) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16198861" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16198861</a>
评论 #16263070 未加载
评论 #16263471 未加载
knodi123over 7 years ago
The example on <a href="https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg</a> shows a binary number ending with zero; doesn&#x27;t that mean it&#x27;s even, and therefore divisible by 2?
评论 #16261923 未加载
评论 #16261911 未加载
评论 #16261901 未加载
notahackerover 7 years ago
Not convinced I actually look like<p><pre><code> 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357110553379400815780032957688591226535854678434413850350192892043530395436831148532011789232552521569332295554081981793617293526812832242447096911185919439189235252915185597964786711096720343</code></pre> tbh ;-)
评论 #16261954 未加载
评论 #16261377 未加载
Retr0spectrumover 7 years ago
You could probably speed things up a lot using isProbablePrime(), at least to pre-filter candidate numbers. (Assuming you&#x27;re using this library: <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;big-integer#isprobableprimeiterations" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;big-integer#isprobableprimeite...</a>)
评论 #16262371 未加载
krishna2over 7 years ago
You could color the 1s and 0s - so the image is more obvious and enhanced.
mbrdover 7 years ago
Relevant Numberphile on generating prime pictures: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=fQQ8IiTWHhg" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=fQQ8IiTWHhg</a>
oh_sighover 7 years ago
Perhaps it shouldn&#x27;t even bother generating a binary number that ends in &#x27;0&#x27;
jchavannesover 7 years ago
Is there a way to link to a number? Or enter a number to view the image?
评论 #16261957 未加载
OskarSover 7 years ago
These are very neat, but all of these I&#x27;ve seen the last few weeks use the same trick of putting some garbage at the end to make it a prime. I wish people would vary their techniques a bit: like, make it base 10 and make an ascii-art image, and introduce imperceptible noise to make it a prime. Or, vary the number of rows and columns, and maybe scale of the image, to make it prime.<p>We need to disrupt the &quot;images as primes&quot; industry!
评论 #16265609 未加载
评论 #16264629 未加载
arsover 7 years ago
Can you use this for encryption? Make the decryption key the prime number generated by this, and you unlock it by pointing the camera at the right thing?
评论 #16261494 未加载
评论 #16261502 未加载
评论 #16266783 未加载
otover 7 years ago
&gt; numberBigInt = numberBigInt.minus(1)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg&#x2F;blob&#x2F;master&#x2F;index.html#L82" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg&#x2F;blob&#x2F;master&#x2F;index.html#L82</a><p>Could go double as fast subtracting 2 instead of 1 (why try the even numbers).
评论 #16265062 未加载
JorgeGTover 7 years ago
Is this in response to <a href="https:&#x2F;&#x2F;mathwithbaddrawings.files.wordpress.com&#x2F;2017&#x2F;10&#x2F;2017-10-6-odd-number-theorists.jpg" rel="nofollow">https:&#x2F;&#x2F;mathwithbaddrawings.files.wordpress.com&#x2F;2017&#x2F;10&#x2F;2017...</a> ?
评论 #16261808 未加载
com2kidover 7 years ago
This takes a very, very, very long time.<p>20 minutes in, it is up to 13388 in Firefox.<p>Funny enough, I ran the same image through Chrome, it said it was finish at iteration 458. I&#x27;m guessing it is not completely deterministic?
评论 #16262310 未加载
jwilkover 7 years ago
Source: <a href="https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;geonnave&#x2F;primg</a>
seertaakover 7 years ago
Ah, but can you generate a prime number that encompasses the full list of true statements, please? :)
memyselfandoover 7 years ago
Would it not be preferrable to change as little bits as possible? Instead of counting up from your number you should first try to change single bits (one bit, two, three ...)<p>Changing a single out of 32<i>32 bits gives you 1024 variations. Changing two already gives you 1024</i>1023&#x2F;2 = 523776 variations.