RANDOM command in PBASIC
The RANDOM command doesn't simply generate a random number for you; what it's actually doing is taking whatever value is already in the variable and transforming it in a pseudorandom way. In other words, the variable you give it is the internal state of the random number generator. You must not modify that variable in any other way if you want the generated numbers to be as random as possible.

When you set randnum = randnum // 2, you are forcing it to be either 0 or 1. It would seem that when the RANDOM command sees a value of 1, it generates a new number that is odd, so you once again set randnum to 1.

What you need to do is use a second variable to hold the binary result:

RANDOM randnum
randbit = randnum // 2


(I can't explain the problem with the loop count changing; that would seem to be a separate issue.)