
Modified Euclidean Algorithm
Problem 1011
In a modified Euclidean algorithm for two numbers $a, b$, at each step we perform Euclidean division of the larger number by the smaller number and then replace the larger number with the integer quotient (rather than the remainder, as in the normal Euclidean algorithm).
This operation is repeatedly performed until one of the two numbers becomes $1$; when this happens, the value of the other number is denoted $f(a, b)$.
For example, $f(123, 456) = 3$ as shown below: $$(123, 456) \to (123, 3) \to (41, 3) \to (13, 3) \to (4, 3) \to (1, 3) \mapsto 3.$$
Let $E(N)$ be the sum $\sum\limits_{1 \le a, b \lt N} f(a, b)$.
You are given $E(10) = 343$ and $E(100) = 269288$.
Find $E(3\,000\,000)$.