The answer given is incorrect. The number of moves required to solve the puzzle should be this sequence, given by $(n^2+n-2)/2$ (where $n=\#\text{ of frogs}$).
Let's write the formation of the frogs as a string of numbers $ 0$ through $ n$, denoting the empty space by $ 0$. With this notation, we can see that each turn is defined by swapping the $ 0$ with the number one or two spaces to the left or right, corresponding to a frog on the left or right hopping or leaping to the right or left, respectively. Since we'll be focusing on the $ 0$, it will be easiest to say that the $ 0$ is leaping to the left when a frog is leaping to the right, and analagously for the other cases.
Now, for aesthetics, we can consider the formations as vertices of a layered tree, each layer of the tree corresponding to a turn of the frog moving game. We put a directed edge from formation $ a$ (in layer $ i$) to formation $ b$ (in layer $ i+1$) if a legal move takes us from $ a$ to $ b$. Viewed in this way we can consider the puzzle as a shortest path problem from $ 0123\ldots n$ to $ n\ldots 3210$ (or to $ n\ldots 3201$, $ n\ldots 3021$, $ n\ldots 0321$, etc). Since we are interested only in shortest paths, the layers of the tree will be disjoint, as moving to an in-neighbor would imply we could have gotten there in fewer moves.
The Even Case.
I find the even case a bit easier to visualize, so let's start with that. Here is what the puzzle looks like with $ 4$ frogs.
You can see there are several solutions, highlighted in red, with the shortest one bolded. Let's zoom into these paths and walk through them.
Every solution follows the same pattern. First, the $ 0$ is moved all the way to the right, then reverses direction. We don't want to undo our previous move, so there is only one one available option - if we leaped right, we need to hop left, and vice versa. When we get $ 0$ back to the leftmost position, we reverse direction again. This process repeats until all the numbers are in order. (See: "Why does this work?") The fastest way to do this is highlighted in the red path - every move to the right is a leap, and there are exactly two hops to the left.
If we say that moving $ 0$ all the way to the right, then all the way back to the left constitutes a "round," then each round takes $ n/2$ leaps to the right + $ 1$ hop to the left + $ (n-2)/2$ leaps to the left + $ 1$ hop to the left. That's $ n+1$ total moves, $ 2$ hops and $ n-1$ leaps. Since each round moves the biggest number to the left twice and the smallest number to the right twice, we only need to do this $ n/2$ times to get everything in order. Also, we can skip the last step (which would only serve to put $0$ on the far left), so the even case requires $$ \frac{n(n+1)}{2}-1 =\frac{n^2+n-2}{2} \text{ moves}$$ with $$\frac{n(n-1)}{2}\text{ leaps}$$ and thus $$n-1\text{ hops.}$$
The Odd Case.
For $5$-frogs, the full diagram is too big, but we can look at its solutions.
Here is where we diverge from the answer given. We can do it in $ 14$ moves, $ 2$ less than $ (5^2+3\times 5)/2-4=16$.
We use essentially the same strategy here as in the even solutions. Let's write out the algorithm explicitly. The starting formation is $ 0123\ldots n$ and the starting direction is $ d=1$. Every turn, check first if $ 0$ is at position $ 1$ or $ n-1$. If it's at position $ p_0= 1$, let the $ 0$ hop left to position $ 0$ and set $ d=1$. If it's at position $ p_0= n-1$, have the $ 0$ hop right to position $ n$ and set $ d=-1$. In any other position $p_0$, the $ 0$ leaps to position $ p_0+2d$. We continue in this manner until the frogs are in the formation $ n\ldots 3201$.
Again we can see that each round has $n+1$ moves, $n-1$ leaps and $2$ hops (now in opposite directions). After completing $ k$ rounds, there are $ 2k-1$ numbers to the right of $ n$. If we do this $ (n-1)/2$ times, we have $ n-2$ numbers to the right of $ n$. In this situation, we only need to complete a 'half round' to finish - that is, once we get $ 0$ back to position $ n-1$, everything will be complete. That's $ (n-1)/2$ leaps, so we have a total of $$\left(\frac{n-1}{2}\right)(n+1)+\frac{n-1}{2}=\frac{n^2+n-2}{2} \text{ moves, }$$
which breaks down to
$$\left(\frac{n-1}{2}\right)(n-1)+\frac{n-1}{2}=\frac{n(n-1)}{2} \text{ leaps }$$
and
$$2\left(\frac{n-1}{2}\right)=n-1 \text{ hops.}$$
Why does this work?
Luckily we can understand our solution using some permutation theory. Let's prove it works for the odd case. Taking $0$ from left to right induces the permutation $$(0,n,n-1,n-3,n-5,n-7,\ldots,8,6,4,2)$$ in $\text{Sym}(\{0,\ldots,n\})$. Taking it from right to left induces the permutation $$(0,1,3,5,7,9,\ldots,n-4,n-2,n).$$ Multiplying these permutations, we get $$\sigma:=(1, 3, 5, 7, 9, 11,\ldots, n,n-1,\ldots,10,8,6, 4, 2).$$ So if we let $\sigma=(\sigma_1,\ldots,\sigma_{n})$, then we have that $$\sigma_k=\left\{\begin{array}{lcl}2k-1&:&k=1,\ldots,\frac{n+1}{2}\\ 2 (n - k + 1) &:&k=\frac{n+1}{2}+1,\ldots,n\end{array}\right.$$ where the indices are taken mod $n$.
Let $m=(n-1)/2$. We have, in general, that in cycle notation we can write $$(i_1,i_2,i_3,\ldots,i_c)^{m}=(i_{1+m},i_{1+2m},i_{1+2m},\ldots,i_{1+cm}),$$ where the indices are taken modulo $c$. From this we obtain
$$\begin{eqnarray*}\sigma^{m}&=&(1, 3, 5, 7, \ldots, 2m+1,2m,\ldots,8,6, 4, 2)^{m}\\&=&(2,n-2,4,n-4,\ldots,m+1,m,\ldots,3,n-1,1,n).\end{eqnarray*}$$
Applying this permutation to $0,\ldots,n$ yields the formation $$0,n-1,n,n-3,n-2,n-4,n-3,\ldots,5,2,3,1.$$ So now, we can see that we just need to leap $n$ to the left, then $n-2$, then $n-3$, etc. until we reach $n,n-1,n-2,\ldots,3,2,0,1$.
The even case is proven identically.
How do we know this is the smallest possible number?
Every move can at most reverse the order of $2$ frogs. We must put frog $n$ to the left of all $n-1$ of the other frogs, so that is at least $n$ leaps right there. This does not modify the order of the other frogs, so to move frog $n-1$ to be to the left of the $n-2$ remaining frogs, we will need at least $n-2$ leaps. Continuing in this fashion, we need at minimum $$\sum_{k=1}^{n-1}k=\frac{n(n-1)}{2}$$ leaps. However, discussed above, we need $1$ hop each for frogs $2$ to $n$ to change direction, so we need at least $$\frac{n(n-1)}{2}+n-1=\frac{n^2+n-2}{2}$$ moves. Thus our construction is of minimal length.
Best Answer
To get the number of moves, look at how many spaces each frog must move. Each frog moves $n+1$ spaces, so there are a total of $2n(n+1)$ spaces moved. There are $n^2$ jumps where a frog moves two spaces, so the number of moves is $2n(n+1)-n^2=n^2+2n=(n+1)^2-1$
To prove that a frog jumping another of the same color cannot be part of the optimum solution, assume it is a green frog. We then must have GG_ with other frogs in the row. How did we get here? The first G could have jumped backwards, but then jumping forwards undoes the move and we would be better without the pair. An R could have moved backwards, but then the front G should have jumped it and we would be farther along. Finally, a G could have moved forwards, but then we had GG_ before (one space to the right) and we look at the move before that.