-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (47 loc) · 1.42 KB
/
Copy pathProgram.cs
File metadata and controls
50 lines (47 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
EulerOne();
}
public static void EulerOne()
{
int x= int.Parse(Console.ReadLine());
int[] dividerArray = {3,5};
int dividerLength = dividerArray.Length;
int sum = 0;
List<int> dividerColletion = new List<int>();
for(int i =0 ; i < dividerLength;i++)
{
var divider = dividerArray[i];
for(int k=divider ; k < x ; k += divider)
{
if(NotIncluded(dividerColletion,k))
{
dividerColletion.Add(k);
sum += k;
}
}
}
Console.WriteLine(sum);
}
public static bool NotIncluded(List<int> collections, int number)
{
bool notIncluded = true;
int collectionLength = collections.Count;
for(int i=0; i < collectionLength; i++)
{
if(collections[i] == number)
{
notIncluded = false;
}
}
return notIncluded;
}
}
}