## Integers in base i-1

### Problem 508

Consider the Gaussian integer i-1. A **base i-1 representation** of a Gaussian integer `a`+`b`i is a finite sequence of digits `d`_{n-1}`d`_{n-2}...`d`_{1}`d`_{0} such that:

`a`+`b`i =`d`_{n-1}(i-1)^{n-1}+`d`_{n-2}(i-1)^{n-2}+ ... +`d`_{1}(i-1) +`d`_{0}- Each
`d`_{k}is in {0,1} - There are no leading zeroes, i.e.
`d`_{n-1}≠ 0, unless`a`+`b`i is itself 0

Here are base i-1 representations of a few Gaussian integers:

11+24i → 111010110001101

24-11i → 110010110011

8+0i → 111000000

-5+0i → 11001101

0+0i → 0

Define

`f`(

`a`+

`b`i) as the number of 1s in the unique base i-1 representation of

`a`+

`b`i. For example,

`f`(11+24i) = 9 and

`f`(24-11i) = 7.

Define

`B`(

`L`) as the sum of

`f`(

`a`+

`b`i) for all integers

`a`,

`b`such that |

`a`| ≤

`L`and |

`b`| ≤

`L`. For example,

`B`(500) = 10795060.

Find

`B`(10

^{15}) mod 1 000 000 007.