9 lines
223 B
Rust
9 lines
223 B
Rust
|
impl Solution {
|
||
|
pub fn sum_of_squares(nums: Vec<i32>) -> i32 {
|
||
|
let n = nums.len();
|
||
|
nums.iter().enumerate()
|
||
|
.filter(|(i, x)| n % (i+1) == 0)
|
||
|
.map(|(i, x)| x*x)
|
||
|
.sum()
|
||
|
}
|
||
|
}
|