title: find first 1500 natural numbers whose factors are either ONLY 2, 3, or 5
body: <p>I have tried:</p>
  
  <pre><code>static void primeFactors(int n)
          {
              int t = 0;
              List&lt;int&gt; lst = new List&lt;int&gt;();
  
              for (int c = 2; c &lt;= n; c = c + 1)
              {
                  t = c;
                  if (t % 2 == 0 || t % 3 == 0 || t % 5 == 0)
                  {
                      Console.Write("{0} : ", t);
                      while (t % 2 == 0)
                      {
                              Console.Write("{0} ", 2);
                          t = t / 2;
                      }
  
  
                      for (int i = 3; i &lt;= Math.Sqrt(t); i = i + 2)
                      {
                          while (t % i == 0)
                          {
                              Console.Write("{0} ", i);
                              t = t / i;
                          }
                      }
  
                      if (t &gt;2)
                          Console.Write("{0}", t);
                      Console.WriteLine();
                  }
              }
          }
  </code></pre>
  
  <p>My Output:</p>
  
  <pre><code>2 : 2
  3 : 3
  4 : 2 2
  5 : 5
  6 : 2 3
  8 : 2 2 2
  9 : 3 3
  10 : 2 5
  12 : 2 2 3
  14 : 2 7 ** should not be list 
  15 : 3 5
  16 : 2 2 2 2
  18 : 2 3 3
  20 : 2 2 5
  21 : 3 7  ** should not be list 
  22 : 2 11  ** should not be list 
  24 : 2 2 2 3
  25 : 5 5
  26 : 2 13  ** should not be list 
  27 : 3 3 3
  28 : 2 2 7  ** should not be list 
  30 : 2 3 5
  </code></pre>
  
  <p>Required Output :
  the first 20 numbers are (factors listed after semicolon):</p>
  
  <pre><code>2 : 2
  
  3 : 3
  
  4 : 2 2 
  
  5 : 5
  
  6 : 2 3
  
  8 : 2 2 2 
  
  9 : 3 3 
  
  10 : 2 5
  
  12 : 2 2 3
  
  15 : 3 5
  
  16 : 2 2 2 2 
  
  18 : 2 3 3 
  
  20 : 2 2 5
  
  24 : 2 2 2 3
  
  25 : 5 5 
  
  27 : 3 3 3 
  
  30 : 2 3 5
  
  32 : 2 2 2 2 2 
  
  36 : 2 2 3 3 
  
  40 : 2 2 2 5
  </code></pre>
  
  <p>Note: <code>14(2*7),21 (3*7), 22 (2*11), 26 (2*13)</code> are numbers that should not be in the list. factors must be either 2, 3 or 5 only</p>