DEV Community

Cover image for 357686312646216567629137
adriens
adriens

Posted on

357686312646216567629137

πŸ‘‰ Intro

As mentionned in my previous post...

I'm a big fan of Numberphile, and recently I felt on this one :

In a few words, the question is :

What is the biggest prime number we can build, which has the following property : "each time we remove a digit from the left side we still get a prime number."

Obviously, the answer is quite straightworward :

Yes it does exist, and it is and the biggest one is 357686312646216567629137. That's all.

❔ The questions

After this very appealing and funny question, I wanted to see :

  • I want to compute it (and generate some additional stuff)
  • What does the structure of the prime numbers ? I mean : what does it look like... as graph ?

πŸ’» Compute it

Well as this stage I wanted to create a little cli that should

  • Take a number of generations as input : the bigger the further I'm looking for such primes
  • Draw the output in the console the funny way so we can see the strange thing appear πŸ˜†
  • Dump a graphml file as output so we can play with it later

Finally, here is the JBang! program you can easily call this way :

jbang https://github.com/adriens/truncatable-primes/blob/main/BigTruncatablePrimes.java -s 30
Enter fullscreen mode Exit fullscreen mode

GitHub logo adriens / truncatable-primes

A proto around Truncatable primes

truncatable-primes

A proto around Truncatable primes

jbang https://github.com/adriens/truncatable-primes/blob/main/BigTruncatablePrimes.java -s 30

Why

Because of this great Numberphile episode.

Which looks like that with a maximum number of generations set to 30 :

At then end of the run, you get a .graphml. So we can now play with it.

🎨Dealing with Gephi

Gephi is an amazing tool to deal with graphs, for analytics purpose, or simply to produce satisfying artworks.

Then I started to play with it, and produced somes. See below some of my favorites.

🌌 Artwork samples

Twin 3 and 7 seeded galaxies

Twin 3 and 7 seeded galaxies

The 3 galaxy

The "3" galaxy

Circular layout

Circular Layout

Do your own visualizations

You can use the ready to use graphml and make your own visualizations, and contribute them to the repo.

Stay curious, experiment things and have fun.

Top comments (0)