## Triangle Of The Gods

### November 10, 2015

The *n*th element of the Smarandache consecutive number sequence (A007908) is the sequence of the numbers from 1 to *n* concatenated in order:

1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 12345678910, 1234567891011, 123456789101112, …

The sequence is sometimes called the “Triangle of the Gods,” and the story goes that anyone who can specify the smallest prime number in the sequence is admitted to heaven.

Your task is to find the smallest prime number in the sequence. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Ok, I’ll be the first one to admit I got trolled :P

Sequence generator:

Scala:

1. stream of Smarandache numbers

2. stream of primes

3. take te common elements

Actually, I’ve had more fun factoring elements of the Smarandache sequence than searching for primes:

Funny that these days I think of writing a generator function first. I could’ve just included that logic in the loop. I blame all the playing around with ranges (i.e. lazy sequences) that I’ve been doing.

I reused the isprime function (not shown) that I’d written for an earlier collatz primes exercise.