Well, you still didn't lose money.
I had almost the same problems with one. On mine, someone had dropped it and bent the focus ring so it was pressing against the filter ring. They tried to force it to focus, and eventually pulled the screws loose that hold that ring on to the lens. I pretty much fixed it but the lens has other issues.
Your lens doesn't look like it was dropped and I'm not sure what else would cause the ring to be stuck. If you want to investigate the problem yourself, you'll need to take off the name ring (part that says SMC Pentax-M 1:2.8 40mm). It unscrews using the filter threads. Find something rubber and round that you can press against the ring to provide friction, and unscrew it. That reveals six screws. Three hold on the filter ring. It'll look almost like this, a Pentax-M 50mm f1.7:
The red arrows point to the screws that hold on the filter ring. )Green arrows point to slots for a tool that will unscrew the front lens group; maybe you can reach the element with fungus from here.) Remove those and pull the ring off. You'll see something like this:
The red arrows point to the three screws attaching the focus ring to the lens.
I don't know exactly what to tell you from here. If you remove the focus ring, your lens will look like this:
The aluminum ring has very fine pitch outer threads into the lens barrel, and very coarse pitch inner threads (focus helix) that move the front lens group in and out. I have seen a lens where that aluminum ring was jammed and would not turn. It had somehow gotten off its outer threads. I was able to snap it back into place and get it working fine again. I didn't know what I was doing then but it worked out anyway. Try to avoid removing the focus helix entirely. The threads engage at three points but only one position is correct, so getting it back together is a puzzle.
If you take off the focus ring you'll have to reset infinity focus when you reassemble. Rotate the aluminum ring so that the lens is as short as possible. Attach the focus ring with one screw. Mount it on a camera and point it at a distant object. The lens should be focused "beyond" infinity. Turn the focus ring until the distant object is sharp. Then loosen the single screw and without changing the focus, turn the ring until the orange diamond points at infinity again. Tighten the screw, check focus, then install the other screws and parts.