title: Trying to find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20
body: <p>I'm trying to find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20. We are given that 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. My find() finds the number starting from 2520 that is divisible by all numbers from 1-20 but is returning 2520 for some reason. I cannot find what's wrong about my find()?</p>
  
  <pre><code>  public class Solution  {
  
    public ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
  
  
  // creating a list of integers from 1 to 20
  public ArrayList&lt;Integer&gt; addtolist() {
    for (int i = 1; i &lt;= 20; i++) {
      list.add(i);
    }
    return list;
  }
  
  // finds the smallest positive number that is evenly divisible by all 
  of the numbers from 1 to 20
  
  public int find() {
    int num = 2520;
    while(true) {
      for(int i: list) {
        if(num % i == 0) {
          return num;
        }
        else {
          num = num + 1;
        }
  
      }
    }
  }
  
  public static void main(String[] args) {
    Solution sol = new Solution();
    sol.addtolist();
    System.out.println(sol.find());//2520
  }
  
  
  }
  </code></pre>