如何在Scala代码
下面使用val而不是varvar index: Long = lower
var sum = 0L
while(index <= upper) {
if(number % index == 0L)
sum += index
index += 1L
}
sum
答案 0 :(得分:1)
(lower to upper).filter(number % _ == 0).sum