title: Project Euler #5(Smallest positive number divisible by all numbers from 1 to 20): Ways to Optimize? ~Java
body: <p><strong>Problem 5:</strong> 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?</p>
  
  <p>I have solved the problem 5 of <a href="http://projecteuler.net/" rel="nofollow">Project Euler</a></p>
  
  <p>Here is the Java code:</p>
  
  <pre><code> static long FindLcm(long a,long b)
   {
       long lcm,hcf = 0;
       long i=1;
       long ger=a&gt;b?a:b;
       while(i&lt;ger)
       {
           if((a%i==0) &amp;&amp; (b%i==0))
               hcf=i;
           i++;
       }
       lcm=(a*b)/hcf;
       return lcm;
   }
   static void FindMultiple()
   {
       long lcm=1;
       for(long i=2;i&lt;=20;i++)
       {
           lcm=FindLcm(lcm,i);
       }   
       System.out.println("Lcm="+lcm);
   }
  </code></pre>
  
  <p>How can optimize this?</p>