In this segment from Rule Breaker Investing, Motley Fool co-founder David Gardner addresses a problem he's heard many times before, but one that always bears revisiting. Which is the wiser use of a person's extra funds: paying off debt -- in this case, student debt -- or building up a portfolio? The answer comes down to interest rates.

A full transcript follows the video.

10 stocks we like better than Under Armour
When investing geniuses David and Tom Gardner have a stock tip, it can pay to listen. After all, the newsletter they have run for over a decade, Motley Fool Stock Advisor, has tripled the market.*

David and Tom just revealed what they believe are the 10 best stocks for investors to buy right now... and Under Armour wasn't one of them! That's right -- they think these 10 stocks are even better buys.

Click here to learn about these picks!

*Stock Advisor returns as of July 6, 2017

This video was recorded on May 31, 2017.

David Gardner: This one comes from Jamie Mason. "Hi! I'm a pharmacist who recently graduated from pharmacy school, and with that I have a lot of student loans to pay back." This, by the way, is a classic question, Jamie. I'm very happy to feature this one as well. We answered this many times, in the past, on our Motley Fool Radio Show back when we used to do AM radio and NPR, so this is a classic and let's have your version of it.

"I also just recently bought my first house, because I didn't want to pay someone's mortgage when I could pay for my own. I first began to like investing in stocks when my grandfather taught [me] about them when I was in middle school. We continued to talk about them, and then I saw Under Armour was having an IPO and I told him he should buy it because being in high school, at the time, everyone was wearing UA gear under their football uniforms and baseball uniforms. He didn't listen to me, and the stock went quickly from $15 to $55 a share, and I never let him live that down after that. I've since started listening to your podcast and become a big fan. I check the market every day and have some already saved in the market, but my question is should I be putting more in the market or putting more money to my student loans? I've been aggressively paying them back with any extra money I have going to them. My ultimate question is should new grads be paying off their student loans by adding on to their standard payment or income-based payment, or should we, with the extra money, invest in the stock market? I don't want to miss out on any multibaggers or spiffy-pops. Thank you! Jamie."

Jamie, it's a great question, and it's very natural because, after all, when you have an extra dollar at the end of the day and you have debt, it becomes very natural to wonder should I be paying off my debt or there's this thing called the stock market which rises 10% a year and if I'm finding better companies than the average index fund is investing in, could I beat that? What should I do with my extra dollar at the end of the day?

I think it comes down to a story of interest rates. I don't know what your student loan interest rate is, but being purely mathematical, here, if it's a low single-digit number -- and for a lot of students that is around the level of their student loan -- I think you're OK continuing to invest in the stock market. Pay it off slowly, as you've already described, I think, that you were doing.

Because it makes a lot more sense, to me, if you have extra money to have it riding on something that's rising 10% or so a year -- and I realize the stock market may be about to sell off 25% just as I say that. We never know where the market's headed, but it makes more sense, taken all in all, to have your money rising and paying off that low-interest loan slowly, separately, and when appropriate.

Now, on the other hand, if we're talking about a higher-interest loan -- if we're talking about credit cards -- it's very obvious every dollar we have should be paying off that debt as quickly as possible. You're not going to be able to maintain a lot of credit card debt and invest in the stock market successfully. The math will simply work against you.

So this is a very coldly mathematical answer from me, but I think it's the right way of thinking about it. And by the way, beyond the cold math, let me just mix in that for some of us, we have a certain orientation or a mentality about things. So for example, for me, I don't like to have debt at all. I just don't like to have it. It's just not part of who I am or how I've been or how I was raised, so I always paid off debt if I had it, and just got rid of it. Didn't want to have it at all.

And I think my stock market returns have suffered a little bit as a consequence, because some of the stocks I pick have been pretty awesome, and I should have actually just maintained a mortgage, let's say, and just held those stocks instead. But for me, that was more my orientation. Maybe that's you. I would not encourage you to go against your natural instincts. However, if you're either way, I think the math works. So I hope that helped.