function floyd (f, x0) {
if(!x0) {
return {};
}
let tortoise, hare, mu, lam, log = [];
log.push(["f", f]);
tortoise = f(x0);
hare = f(f(x0));
while (!tortoise.equal(hare)) {
tortoise = f(tortoise);
hare = f(f(hare));
}
log.push(["loop found"]);
mu = 0;
tortoise = x0;
while (!tortoise.equal(hare)) {
tortoise = f(tortoise);
hare = f(hare);
mu += 1;
}
log.push(["mu found"]);
lam = 1;
hare = f(tortoise);
while (!tortoise.equal(hare)) {
hare = f(hare);
lam += 1;
}
log.push(["lamda found"]);
return {lam, mu, log};
}