fun Int.getFactors(): List<Int>{
    var returnList: MutableList<Int> = emptyList<Int>().toMutableList()
    returnList.add(1)
    val squareRoot: Int = Math.sqrt(this.toDouble()).toInt()
    for (i in (2..squareRoot)){
        if (this.rem(i) == 0){
            returnList.add(i)
            returnList.add(this/i)
        }
    }
    return returnList
}


enum class Classification {
    DEFICIENT, PERFECT, ABUNDANT
}

fun classify(naturalNumber: Int): Classification {
    if (naturalNumber < 1) throw RuntimeException()

    val aliquotSum: Int = naturalNumber.getFactors().sum()
    if (aliquotSum == naturalNumber){
        return Classification.PERFECT
    }
    else if (aliquotSum > naturalNumber){
        return Classification.ABUNDANT
    }
    else return Classification.DEFICIENT
}
