JSFiddle - React, Tailwind, and code Playground
JavaScript
var a, b, c, n = 0, i;
var aaa=0;
var abc=0;
var iter=10000;
var alf = 10;
for (i = 0; i < iter; i++) {
a = Math.floor(Math.random()*alf);
b = Math.floor(Math.random()*alf);
c = Math.floor(Math.random()*alf);
//0 a, 1 b, 2 c
n = 0
n += 3;
//aaa
while (a != 0 || b != 0 || c != 0)
{ a = b; b=c; c = Math.floor(alf*Math.random()); n++; }
aaa += n;
a = Math.floor(Math.random()*3);
b = Math.floor(Math.random()*3);
c = Math.floor(Math.random()*3);
n = 0;
//abc
while (a != 0 || b != 1 || c != 2)
{ a = b; b=c; c = Math.floor(alf*Math.random()); n++; }
abc += n;
}
alert("aaa: " + aaa/iter + "\nabc: " + abc/iter);