## Triangle Of The Gods

### November 10, 2015

This is a trick question. No such prime number is known, though it is conjectured that an infinite number of them exist. All terms of the sequence up to *n* = 270,000 have been tested and found to be composite. Here’s our program to generate and test elements of the sequence:

> (let loop ((i 1) (n 1)) (display n) (newline) (if (prime? n) (display "PRIME!") (loop (+ i 1) (+ (* n (expt 10 (size (+ i 1)))) i 1)))) 1 12 123 1234 ...

You can run the program at http://ideone.com/hoYqVc, where you will also see the definitions of `ilog`

, `prime?`

and `size`

.

Advertisements

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.