Ad
  • Custom User Avatar

    const listSquared = (m, n) => {
    let list = [];
    for (let i = m; i <= n; i++) {
    let divisors = [];
    for (let k = 1; k <= i; k++) {
    i % k === 0 ? divisors.push(k) : divisors;
    }
    let sqrt = Math.sqrt(
    divisors.reduce((prev, curr) => {
    return prev + Math.pow(curr, 2);
    }, 0)
    );
    if (Math.floor(sqrt) === sqrt) {
    list.push([i, Math.pow(sqrt,2)]);
    }
    }
    return list;
    };