I think the upper-bound complexity should be the sum of three parts:
- the complexity of multiple $a$ and $b$
- the complexity of $\gcd(a,b)$
- the complexity of division
For (1), the complexity is $O(n^2)$
How to compute the complexity of gcd and the complexity of division?
Reference: https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations
Both GCD and division take $O(n^2)$ time, so overall complexity is $O(n^2)$.
Note that faster algorithms are mentioned in the reference, so it can be done even faster, just see the link for more information.