04-18-2004, 07:00 AM
Andy, I analysed and tested your code and found what was wrong, so I interchaged the two IF's. Now it works.
*****
Code:
DEFINT A-Z
RANDOMIZE TIMER
input a
for i = 1 to a
flip = int(rnd * 2) + 1
if flip = 1 then 'Tails=1, Heads=2
t = t + 1
if maxt < t then maxt = t 'modified
h = 0
else
h = h + 1
if maxh < h then maxh = h 'modified
t = 0
end if
next i
print "Consecutive heads: "; maxh;" consecutive tails: ";maxt