• + 0 comments

    for JS

    interface AdvancedArithmetic{
        divisorSum(n: number): number;
    }
    
    class Calculator implements AdvancedArithmetic
    {
        divisorSum(n: number): number {
            let sum = 0
            
            for (let i = 1; i < (n + 1) / 2; i++) {
                if (n % i === 0) {
                    sum += i
                }
            }
            
            return sum + n
        }
    }