What is the smallest number divisible by each of the numbers 1 to 20?

**Problem:**

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 number that is evenly divisible by all of the numbers from 1 to 20?

**My Solution:**

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Euler
{
class Problem5 : IProblemBase
{
//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 number that is evenly divisible by all of the numbers from 1 to 20?
public Problem5()
{
}
public string GetAnswer()
{
bool foundThemAll = false;
int smallestNumberDivisible = 0;
while (foundThemAll == false)
{
bool foundThemAllInner = true;
smallestNumberDivisible++;
for (int i = 1; i <= 20; i++)
{
if (smallestNumberDivisible % i != 0)
{
foundThemAllInner = false;
break;
}
}
if (foundThemAllInner)
{
foundThemAll = true;
}
}
return smallestNumberDivisible.ToString();
}
}
}

### Like this:

Like Loading...

*Related*

## Leave a Reply