题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
import java.util.Scanner fun main(args: Array<String>) { val read = Scanner(System.`in`) val res = read.nextLine().toInt() var sum = 0 for (j in 2 .. res) { var mul = 1 for (i in 2 .. Math.sqrt(j.toDouble()).toInt()) { if(j % i == 0) mul += i + j/i } if(mul == j) { sum ++ } } print(sum) }