Question: Generate bitstrings of length n that do not contain two consecutives ones

Hello I was wondering how to generate bitstrings of length n that do not contain two consecutives ones. So far i have the following bitstring := x[i]; for i to 5 do bitstring := [op(bitstring), rand(2)()]; if x[i] = 1 then x[i+1] = 0 else x[i+1] = rand(2)() end if end do; bitstring there are two problems with this: (1) this is not from 1 to n (and i don't know how to specify this) (2) It produces strings which do have consecutive ones. Thank you in advance any help, Herman
Please Wait...