Note: According to the prime number theorem, the density of prime numbers is asymptotically of order 1/log(n). Hence, if we have some number n with m

LeviBorodenko/primify

submited by
Style Pass
2023-01-27 05:00:12

Note: According to the prime number theorem, the density of prime numbers is asymptotically of order 1/log(n). Hence, if we have some number n with m digits, the number of primality tests that we expect to do until we hit a prime number is roughly proportional to m. Since we use the Baillie–PSW primality test, the overall expected computational complexity of our prime searching procedure is O(n*log(n)³).

Simply get the primify command line tool via pip install primify. You can also import the PrimeImage class from primify.base or use cli.py as a command-line script.

Thus, if you have the source image at ./source.png and you want to convert it into a prime contained in ./prime.txt which has at most 5000 digits. Then you should run:

You can also simply import the PrimeImage class from primify.base and use that class in your own code. Check the documentation for details on how to interact with the underlying API.

Daniel Temkin wrote a lovely article on his blog esoteric.codes giving some interesting insight and background for this tool. You can read it here.

Leave a Comment
Related Posts