Can you solve this project euler problem? You can use code to solve it, but don't do any…
- User
Can you solve this project euler problem? You can use code to solve it, but don't do any web searches:
The Fibonacci sequence is the unique sequence such that
Similarly, there is a unique function $A(m, such that
Define . For example
- Assistant
Here’s a sketch of the solution and the final answer.
- Closed‐form for A(m,n)
One shows that the single‐variable sequence
satisfies
whose characteristic roots are
and hence
Then one checks by induction that
- Reducing the double sum
We want
In the ringZ/MZ[13]\Bbb Z/M\Bbb Z[\sqrt{13}]Z/MZ[13]with
one lets
and computes
aspairs(a,b)(a,b)(a,b)representinga+b13a+b\sqrt{13}a+b13moduloMMM. Then
and one shows algebraically that
Here exponentiationufju^{f_j}ufj,pfip^{f_i}pfiis done by fast (“square‑and‑multiply”) inO(logfk)O(\log f_k)O(logfk)steps each.
- Final result
Using this method in code (no web searches), one finds