title: Finding the Greatest Common Divisor using Java Stream without recursion while/for loops
body: <p>Please help me out here. I need to convert the following code to one that uses Java Streams. The method used is the Euclidean Algorithm</p>
  
  <pre><code>public int gcd(int m, int n) {
      if (n == 0) {
          return m;
      } else {
          return gcd(n, m%n);
      }
  </code></pre>
  
  <p>I have already tried to use streams in the following way, however recursions are not allowed and I am stuck at trying to come up with a way <strong>without recursion and loops</strong> since I am still new to the declarative approach</p>
  
  <pre><code>return IntStream.of(m, n).reduce(0, (x, y) -&gt; gcd(n, m-n));
  </code></pre>