I need to apply this experiment:
For all numbers between [0,128] let be t
{set total=0
repeat this experiment n times
{set start=0 choose random number [0,255] lets be R
While(R!=t)
{shift R by multiply by 2 and take the reminder on 256
choose randomly a bit and added to R
increase start by one}
add start to total }
print(total/n)
}
if any body can help me applying this algorithm,thanks in advance this is my code it's not working at all
For[i = 0, i < 10,
i++ {a = 0;
For[j = 0, j < n,
j++, {b = 0; d = RandomInteger[127]; Print[d];
While[d != i, {b = b + 1; c = RandomInteger[];
d = Mod[d*2, 256] + c}]} a = a + b]}]