You are viewing a single comment's thread. Return to all comments →
js
const map = { 0: 0, 1: 1 }; function downToZero(n) { for (let i = 2; i <= n; i++) { if (map[i]) continue; let a = 2; let min = map[i - 1]; let b; while (a <= (b = i / a)) { if (Math.floor(b) === b) { min = Math.min(min, map[b]); } a++; } map[i] = min + 1; } return map[n]; }
Seems like cookies are disabled on this browser, please enable them to open this website
Down to Zero II
You are viewing a single comment's thread. Return to all comments →
js