Sum of Prime Numbers

Published by persolut in

Create a function that takes a list of numbers and returns the sum of all prime numbers in the list.

Examples

SumPrimes(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }) ➞ 17

SumPrimes(new int[] { 2, 3, 4, 11, 20, 50, 71 }) ➞ 87

SumPrimes(new int[] { }) ➞ 0

Notes

  • Given numbers won't exceed 101.
  • A prime number is a number which has exactly two divisors (1 and itself).
Watch a quick demo on how Edabit works.