title: Using recursion and implementing Euclid's algorithm to find GCD of three numbers from user
body: <p>I am wanting to ask the user to input three numbers and then have program calculate the GCD using Euclid's algorithm all the while using recursion.  </p>
  
  <p>My code right now implements two input numbers.  I understand the approach of calculating the GCD of a and b, and calling it result d. Then using the third input (c) and d to find the GCD and essentially repeating Euclid's algorithm again; I am not sure how to implement this in code.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class RecursionDemo {
  
  public static void main (String[] args) {
  
  Scanner userInput = new Scanner(System.in);
  
       System.out.println("Enter first number: ");
       int a = userInput.nextInt();
  
       System.out.println("Enter second number: ");
       int b = userInput.nextInt();
  
  
       System.out.println("GCD is: " + gCd(a, b));
     }
  
       public static int gCd(int a, int b) {
  
       if(b == 0){
           return a;
          }
       return gCd(b, a%b);         
     }
  }   
  </code></pre>
  
  <p>The part that is really throwing me off is using recursion to solve my problem.  </p>
  
  <p>So far I know I need to implement:</p>
  
  <pre><code>System.out.println("Enter third number: ");
       int c = userInput.nextInt();
  
  d = //Not sure here
  
  //And then modify my recursion method to find GCD.
  </code></pre>
  
  <p>Any help or suggestions would greatly be appreciated!</p>