fun with HP-15C
Unless you have a time machine and a need to factorize numbers, this is going to be pretty useless...
sto 0 // reg 0 = x
// we are going to count from 2 to sqrt(x), so
// counter="2.sss01", where sss is sqrt(x)
// at this point, stack=s x x x
sto 1 // reg 1 = i
// at this point, stack=. x x x
// stack=i x x x
goto 1 // we have a divider!
// we are done, x is now a prime
roll down // x x x .
// last_x contains the future value of x (nx)
// at this point, stack = nx x x x
int // i nx x x
// display i to the user
roll down // nx x x i
// this is going to be inefficient, but works:
// just start over