array.forEach(n => {
const repeat = Math.sqrt(n);
const result = [[], []];
for (let i = 1; i <= repeat; i++) {
if(n % i === 0) {
result.push(i);
if (i !== repeat) result.push(n / i);
}
}
result.sort().reverse()[0]
}
)
array.forEach(n => {
const repeat = Math.sqrt(n);
const result = [[], []];
for (let i = 1; i <= repeat; i++) {
if(n % i === 0) {
result.push(i);
if (i !== repeat) result.push(n / i);
}
}
result.sort()[result.length-1]
}
)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
first item after reverse | |
last item after sort |
This benchmark does not have any results yet. Be the first one to run it!