title: How do I find the smallest number than can be divided by all numbers 1:n with no remainder?
body: <p>I have been trying to solve problem number 5 on Project Euler which goes like</p>
  <blockquote>
  <p>2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.</p>
  <p>What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?</p>
  </blockquote>
  <p>I decided to go a step further and I decided I'd make it find the smallest positive number that is evenly divisible by all of the numbers from 1 to <strong>limit</strong> where <strong>limit</strong> is user-defined.</p>
  <p>Problem starts when I execute my program, it immediately prints out 0. I tried tracing my code but that didn't work out.</p>
  <pre><code>#include &lt;iostream&gt;
  using std::cout;
  using std::cin;
  
  bool isRemainderFree(int num, int limit){
      bool bIsRemainderFree = true;
      if(num &lt; limit){
          bIsRemainderFree = false;
      }else{
          for(int i=1; i &lt;= limit; i++){
          if(num % i != 0){
              bIsRemainderFree = false;
              break;
          }
        }
      }
      return bIsRemainderFree;
  }
  
  int smallestMultiple(int limit){
      int smallestNum = 10;
      for(int i=1; i &lt;= limit; i++){
          bool bFree = isRemainderFree(i, 10);
          if(bFree){
              cout &lt;&lt; i &lt;&lt; &quot; is divisible by all numbers from 1 to &quot; &lt;&lt; limit &lt;&lt; &quot;.\n&quot;;
              smallestNum = i;
              return smallestNum;
              break;
          }
      }
  
  }
  
  int main(){
      int limit;
      cin &gt;&gt; limit;
      int smallestNum = smallestMultiple(limit);
      cout &lt;&lt; smallestNum;
      return 0;
  }
  </code></pre>