kumikill
3/30/2016 - 1:04 PM

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 nu

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?

using System;

public class Program
{
    public static void Main()
    {
        int i = 1;
        int mod = 1;

        do
        {
            mod = 0;
            for (int j = 1; j <= 20; j++)
            {
                mod += i % j;
                if (mod != 0)
                {
                    i++;
                    break;
                }
            }  
        } while (mod != 0);

        Console.WriteLine(i);
    }
}