function r(k, r1, r2){
  if(k>0){var a = 0; r(k-1,
        function(){a = (a*23+3)%1000; return a;}, r1)}
      else{var n = 0;
      for(var j = 0; j<3; ++j) document.write(" "+r1());
      for(var j = 0; j<3; ++j) document.write(" "+r2());
      r2();
      while(r1() != r2()) {++n; r2();}
      document.write(" = "+n);
      }
}
r(2, 0, 0);

3 72 659 3 72 659 = 99