Project Euler 304 - Primonacci

Official link:

Thought Process

From Problem 435 I already made a fibonacci mod function, which I copied for this problem.

To find a(n) I use my Miller Primality Test, which is guaranteed to find primes, I simply try every number after n and see if it is a prime. I originally made the miller test for Problem 291 but didn't end up using, so glad it was useful!

But as it turned out once I got the correct answer, I tried using my Fermat Primality Test with 5 tests and it ended up being correct and faster...

I have added both my Fermat Primality test and Miller Primality test to my essential functions page and it is already implemented in my math module

Interactive Code

Input an integer (yourinput)

∑b(n) mod 1234567891011 for 1 ≤ n ≤ yourinput