I almost wish I'd never thought of this problem... I was tearing my hair out over it all night.
Suppose we have a rectangle with side lengths $a$ and $b$, $a,b \in \mathbb Z$, $GCD(a,b)=1$, and $b \gt a$. I want to pack squares in this rectangle in such a way that, at each step, I pack a squares that is large as possible at that step, and that touches the square I packed at the last step. A square packing of this type might end up looking something like this:
My question is this: can I find a formula for the number of squares needed to pack a rectangle in terms of its side lengths $a$ and $b$?
Here is what I tried:
First I let $f(a,b)$ denote the function whose output is the number of squares required. First, I noted a few properties of $f(a,b)$: $$f(a,a)=1$$ $$f(ka,kb)=f(a,b)$$ $$f(a,a+1)=a+1$$ $$f(a,b)=\Big\lfloor \frac{a}{b} \Big\rfloor + f(b, a\mod b)$$ $$r \lt a \implies f(a,qa+r)=q+f(r,a)$$ Next I tried this: I decided to let $b=q_1a+r_1$ where $r_1 \lt a$. Then I would have $$f(a, q_1a+r_1)=q_1+f(r_1, a)$$ Then I decided to let $a=q_2r_1+r_2$, so that we would then have $$f(a, q_1a+r_1)=q_1+f(r_1, q_2r_1+r_2)$$ $$f(a, q_1a+r_1)=q_1+q_2+f(r_2, r_1)$$ and so on. I keep continuing this process until I hit some $n$ for which $r_n=0$, and I will have $$f(a, q_1a+r_1)=\sum_{i=1}^n q_i$$ ...and then I got stuck. How can I find each of the $q_i$s? Somebody, please help! The solution need not be closed-form, it just needs to be... something. I just have no idea where to go with this.
Thanks for any and all help!

$$f(a,b) = \begin{cases}1 & a= b\\b/a & (\gcd(a,b) = a) ∧ (a\neq b)\\ a/b & (\gcd(a,b) = b) ∧ (a\neq b) \\ f(b,a) & b>a\\ \frac{(a-(a \mod b))}{b} + f(b,(a\mod b)) &a>b\end{cases}$$
$$\gcd(x,y) =\begin{cases}x&x=y\\y & (x = 0)∧(x\neq y)\\x & (y=0)∧(x\neq y)\\\gcd(y,(x\mod y))&x>y\\\gcd((y\mod x),x)&y> x\end{cases}$$
(∧: AND logical operator)
$f(a,b)$ is the function that solves your question, using $\gcd(x,y)$, Euclid's GCD function.
Here's also the code written in Swift that does the same thing:
It can be run here, just change the $8$ and $3$ to the numbers you want to put into the function.