Skip to content

Instantly share code, notes, and snippets.

@alefcarlos
Created January 8, 2019 01:38
Show Gist options
  • Save alefcarlos/ebd3bf80940425002dca335111151e4a to your computer and use it in GitHub Desktop.
Save alefcarlos/ebd3bf80940425002dca335111151e4a to your computer and use it in GitHub Desktop.
using System.Linq;
....
public static int SumOfMultiples(int max, params int[] possibleMultiples)
{
int sum = 0;
//Validate if the number is MultipleOf, then sum it
for (int value = 1; value < max; value++)
sum += possibleMultiples.Any(y => Helpers.IsMultipleOf(y, value)) ? value : 0;
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment