I need the equation for this problem:

I sold some books for $10 total on the Internet. If I had sold them at my garage sale I only would have received $6 or $4 less. What percentage did I gain by selling on the Internet?

You would have sold them for $6 in the garage sale. Your real question is what percentage of your basic $6 did you gain by selling them for $4 more.

In other words, what percentage of six is four?
(4/6) * 100 = 66 2/3 percent

Another way to look at it is you sold for ten instead of for six dollars.
(10/6) * 100 = 166 2/3 percent
Now how much you gained is how much more than 100 percent that result is
or once again 166 2/3 - 100 = 66 2/3 percent gained.