JSFiddle - React, Tailwind, and code Playground
JavaScript
function cubicRoot(a) {
let d = Math.floor((a.toString(2).length-1)/3);
let x = 2n ** BigInt(d);
let o=BigInt(0);
let u=BigInt(0);
let i=0;
while(i<d) {
i++;
u = o;
o = x;
y = x*x*x;
if(y===a) return {x, i};
x = ( a / (x*x) + 2n* x ) / 3n;
if(o==x || u==x) return {x:false, i};
}
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>`));