aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/barroff/julia/ch-1.jl
blob: 95e2c8d54188fb9bed82f2eccf1131d36fd3156c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env julia

using Test: @test, @testset

function special_numbers(n::Vector{T}) where {T<:Integer}
	return sum(map(x -> n[x]^2, filter(x -> length(n) % x == 0, 1:length(n))))
end

@testset "special numbers" begin
	@test special_numbers([1, 2, 3, 4]) == 21
	@test special_numbers([2, 7, 1, 19, 18, 3]) == 63
end