Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- List<int> multiple3 = new List<int>();
- List<int> multiple5 = new List<int>();
- List<int> doubles = new List<int>();
- int result = 0;
- public Program()
- {
- }
- public void Multiple3()
- {
- for (int i = 1; i < 1000; i++)
- {
- if (i % 3 == 0)
- {
- multiple3.Add(i);
- }
- }
- }
- public void Multiple5()
- {
- for (int i = 1; i < 1000; i++)
- {
- if (i % 5 == 0)
- {
- multiple5.Add(i);
- }
- }
- }
- public void Addition()
- {
- for (int i = 0; i < multiple3.Count; i++)
- {
- for (int j = 0; j < multiple5.Count; j++)
- {
- if (multiple3[i] == multiple5[j])
- {
- doubles.Add(multiple3[i]);
- }
- }
- }
- result = multiple3.Sum() + multiple5.Sum() - doubles.Sum();
- Console.WriteLine("{0}", result);
- }
- static void Main()
- {
- Program program = new Program();
- program.Multiple3();
- program.Multiple5();
- program.Addition();
- for (; ; )
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment