-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path005.cs
More file actions
49 lines (39 loc) · 1.05 KB
/
Copy path005.cs
File metadata and controls
49 lines (39 loc) · 1.05 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Smallest multiple
//Problem 5
//2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
//What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
namespace _005
{
class Program
{
static void Main(string[] args)
{
int x = 0;
bool found = false;
while (!found)
{
x += 20;
for (int y = 19; y > 1; y--)
{
if (!divisibleBy(x, y))
break;
if (y == 2)
found = true;
}
}
Console.WriteLine(x);
}
static bool divisibleBy(int number, int divisor)
{
if (number % divisor == 0)
return true;
else
return false;
}
}
}