Created
February 1, 2016 23:31
-
-
Save gabeb1920/b543031d6a31b93b7784 to your computer and use it in GitHub Desktop.
Euler Project 1 in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int totalSum = CalculateSumOfMultiples(3, 1000) + CalculateSumOfMultiples(5, 1000) - CalculateSumOfMultiples(15, 1000); | |
Console.WriteLine("The sum of all multiples of 3 and 5 below 1000 is: " + totalSum); | |
Console.ReadLine(); | |
} | |
private static int CalculateSumOfMultiples(int divisor, int max) | |
{ | |
int sum = 0; | |
for(int i = 0; i * divisor < max; ++i) | |
{ | |
sum += i * divisor; | |
} | |
return sum; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment