Being a bit of a nerd myself, I found the problem itself quite interesting, and since it didn't seem that difficult at first glance, I eventually solved it. The only tricky bit was getting my hands on the 10 digit primes set. Anyway, my approach was to write an algorithm in MATLAB to get the answer.

Directly below is the main function, and further below are some auxiliary functions used in the main one.

**Click on the images to enlarge.**

The one below is self explanatory: parity check function.

The one below proved very helpful in the main code, since it allowed to perform arithmetic between vectors (digits of e) and scalars (primes). It converts a 1D array into a scalar (well actually into a string consisting of the original array entries), for any integer array. It does not actually convert it into scalar (consider an array with 0 in the first column), but the sieve in the main code skips all such cases.

And upon execution ... BINGO!

## 2 comments:

Please explain, plese.

What are vectors doing in mathematics of prime numbers?

They're not used here in the "mathematics of prime numbers" as you put it, but in the algorithm used to match scalars (primes in this case) with vectors i.e. 1 dimensional array elements.

I converted the consecutive digits of e: 2.7182818... into consecutive entries of a vector e: [2,7,1,8,2,8,1,8,...]. This way the algorithm can compare whether those entries match some prime i.e. the first 10 digit one.

Post a Comment