Java solution to Project Euler Problem 5

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?

Running time: 125ms

Assessment: LOL.

2 thoughts on “Java solution to Project Euler Problem 5

  1. And here is my solution which is easier to understand ;

    public static void main ( String []args)
    {
    int a = 2520;
    int b = 1;
    while (true)
    {
    if (a%b==0)
    {
    b++;
    if (b==20)
    {
    System.out.println(a);
    break;
    }
    }
    else
    {
    a++;
    b=1;
    }
    }

    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *