JSFiddle - React, Tailwind, and code Playground
JavaScript
function cubicRoot(a) {
let d = Math.floor((a.toString(2).length-1)/3);
let r = 2n ** BigInt(d+1);
let l= 2n ** BigInt(d);
let x=BigInt(l);
let o=BigInt(0);
let i=0;
while(1) {
i++;
o = x;
y = x*x*x;
y<a ? l=x : r=x;
if(y===a) return {x, i};
x = l + (r - l) / 2n;
if(o===x) return {x:false, i};
}
}
let maxDigits=334
let test = [...Array(maxDigits)].map((x,i) => "9".repeat(i+1));
// we can add 1 like that: BigInt(x)-1n to last factor
// and get false as result from cubicRoot but number
// of iterantions change only about ~1-4.
let testB = test.map( x=> BigInt(x)*BigInt(x)*BigInt(x) );
let r = testB.map(x=>cubicRoot(x));
r.map((y,i)=> document.body.innerHTML+=(`<pre>input digits:${testB[i].toString().length}, iterations: ${y.i}, result: ${y.x}</pre>`));