You are viewing a single comment's thread. Return to all comments →
It's confusing because in the example input both odd numbers and numbers with odd indexs produce the same results: 16
(apply + (take-nth 2 (rest [2 3 4 6 5 7 8 0 1])))
(apply + (filter (fn [x] (not= (mod x 2) 0)) [2 3 4 6 5 7 8 0 1]))
Sum of Odd Elements
You are viewing a single comment's thread. Return to all comments →
It's confusing because in the example input both odd numbers and numbers with odd indexs produce the same results: 16
(apply + (take-nth 2 (rest [2 3 4 6 5 7 8 0 1])))
(apply + (filter (fn [x] (not= (mod x 2) 0)) [2 3 4 6 5 7 8 0 1]))