title: Finding the GCD without looping - R
body: <p>So I'm trying to learn <strong>R</strong> and using a number of resources including a book called "Discovering Statistics using R" and a bunch of other cool eBooks.</p>
  
  <p>I understand a great method in programming is the Euclid's Algorithm.</p>
  
  <p>Implementing it in a loop can be achieved like this:</p>
  
  <pre><code> gcd(x,y) //assuming x is the largest value
   //do
   r = x%y;
   x = y;
   y = r;
   //while r != 0;
   return x;
  </code></pre>
  
  <p>After several searches on Google, SO and Youtube refreshing my memory of gcd algorithms, I wasn't able to find one that doesn't use a loop. Even recursive methods seem to use loops.</p>
  
  <p>How can this be achieved in R without the use of loops or if statements?</p>
  
  <p>Thanks in advance.</p>