## Exploding sequence

### Problem 492

Define the sequence a_{1}, a_{2}, a_{3}, ... as:

- a
_{1}= 1 - a
_{n+1}= 6a_{n}^{2}+ 10a_{n}+ 3 for`n`≥ 1.

Examples:

a_{3} = 2359

a_{6} = 269221280981320216750489044576319

a_{6} mod 1 000 000 007 = 203064689

a_{100} mod 1 000 000 007 = 456482974

Define B(`x`,`y`,`n`) as ∑ (a_{n} mod `p`) for every prime `p` such that `x` ≤ `p` ≤ `x`+`y`.

Examples:

B(10^{9}, 10^{3}, 10^{3}) = 23674718882

B(10^{9}, 10^{3}, 10^{15}) = 20731563854

Find B(10^{9}, 10^{7}, 10^{15}).