All M42 lenses, whether Pentax or other manufacturers will work on any Pentax dslr with an adapter.
However, the OP may not realize that they will not autofocus. Nor will the camera be able to control the aperture. It won't even close the aperture down at the momenr ot exposure.
As the OP seems to be a Spotmatic user, he/she will not be uncomfortable doing "stop down" metering.
There is a topic, elsewhere in this forum, discussing just this topic:
Using Manual Lenses (M42 Screwmount, M , K) on Pentax DSLRs F-- - PentaxForums.com
I love using my 50mm, f/1.4 Super Takumar on my K10d.