title: Smallest number that is evenly divisible by all of the numbers from 1 to 20?
body: <p>I did this problem [<a href="http://projecteuler.net/index.php?section=problems&amp;id=5" rel="nofollow noreferrer">Project Euler problem 5</a>], but very bad manner of programming, see the code in c++, </p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  // to find lowest divisble number till 20
  
  int main()
  {
  int num = 20, flag = 0;
  
  while(flag == 0)
  {
      if ((num%2) == 0 &amp;&amp; (num%3) == 0 &amp;&amp; (num%4) == 0    &amp;&amp; (num%5) == 0 &amp;&amp; (num%6) == 0 
      &amp;&amp; (num%7) == 0 &amp;&amp; (num%8) == 0 &amp;&amp; (num%9) == 0 &amp;&amp; (num%10) == 0 &amp;&amp; (num%11) == 0 &amp;&amp; (num%12) ==0   
      &amp;&amp; (num%13) == 0 &amp;&amp; (num%14) == 0 &amp;&amp; (num%15) == 0 &amp;&amp; (num%16) == 0 &amp;&amp; (num%17) == 0 &amp;&amp; (num%18)==0
      &amp;&amp; (num%19) == 0    &amp;&amp; (num%20) == 0)       
  
      {
          flag =  1;
          cout&lt;&lt; " lowest divisible number upto 20 is  "&lt;&lt; num&lt;&lt;endl;
      }
  
      num++;
  }
  
  }
  </code></pre>
  
  <p>i was solving this in c++ and stuck in a loop, how would one solve this step......</p>
  
  <ul>
  <li>consider num = 20 and divide it by numbers from 1 to 20</li>
  <li>check whether all remainders are zero, </li>
  <li>if yes, quit and show output num</li>
  <li>or else num++</li>
  </ul>
  
  <p>i din't know how to use control structures, so did this step</p>
  
  <pre><code>if ((num%2) == 0 &amp;&amp; (num%3) == 0 &amp;&amp; (num%4) == 0    &amp;&amp; (num%5) == 0 &amp;&amp; (num%6) == 0 
  &amp;&amp; (num%7) == 0 &amp;&amp; (num%8) == 0 &amp;&amp; (num%9) == 0 &amp;&amp; (num%10) == 0 &amp;&amp; (num%11) == 0 &amp;&amp; (num%12) ==0   
  &amp;&amp; (num%13) == 0 &amp;&amp; (num%14) == 0 &amp;&amp; (num%15) == 0 &amp;&amp; (num%16) == 0 &amp;&amp; (num%17) == 0 &amp;&amp; (num%18)==0
  &amp;&amp; (num%19) == 0    &amp;&amp; (num%20) == 0) `
  </code></pre>
  
  <p>how to code this in proper manner?</p>
  
  <p>answer for this problem is:</p>
  
  <pre><code>abhilash@abhilash:~$ ./a.out 
   lowest divisible number upto 20 is  232792560
  </code></pre>