title: Difference between 'exec' and 'select'; prime factorization algorithm
body: <p>First, I can't understand the difference between <code>exec</code> and <code>select</code> in <code>kdb</code>. The <a href="http://code.kx.com/q/ref/qsql/#exec" rel="nofollow noreferrer">reference for exec</a> doesn't really help much!</p>
  
  <p>Second, I'm trying to write a program to solve <a href="https://projecteuler.net/problem=5" rel="nofollow noreferrer">Euler problem 5</a>. I solved it by using <code>mod</code> and <code>each</code>, but its slow and requires a ton of space. I believe I can do it by adding up the values of 20's prime factorization. Is that correct? If so, can anyone assist me in doing so? I've written the following to get the prime factorization. It can't take in a list yet.</p>
  
  <pre><code>f1:{(x mod y) = 0}
  f2:{if[f1[a;y]&amp;(not max f1[y;x],0);x:x,y];x}
  f3:{x+:1;y:f2[y;x];if[x&lt;a;y:.z.s[x;y]];y}
  f3[1;()
  </code></pre>