X48: sum13

Write a function in Java that takes an array and returns the sum of the numbers in the array, or 0 if the array is empty. Except the number 13 is very unlucky, so it does not count any 13, or any number that immediately follows a 13.

Examples:

sum13({1, 2, 2, 1}) -> 6
sum13({1, 1}) -> 2
sum13({1, 2, 2, 1, 13}) -> 6

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.