You can change values in the boxes before starting animation

Output

Variable Name     Value in Memory
            n1
            n2
            k
           n1
           n2
              gcd
  1  import java.util.Scanner;
  2  
  3  public class GreatestCommonDivisorMethod {
  4    /** Main method */
  5    public static void main(String[] args) {
  6      // Create a Scanner
  7      Scanner input = new Scanner(System.in);
  8  
  9      // Prompt the user to enter two integers
 10      System.out.print("Enter first integer: ");
 11      int n1 = input.nextInt();
 12      System.out.print("Enter second integer: ");
 13      int n2 = input.nextInt();
 14  
 15      System.out.println("The greatest common divisor for " + n1 +
 16        " and " + n2 + " is " + gcd(n1, n2));
 17    }
 18  
 19    /** Return the gcd of two integers */
 20    public static int gcd(int n1, int n2) {
 21      int gcd = 1; // Initial gcd is 1
 22      int k = 1; // Possible gcd
 23      
 24      while (k <= n1 && k <= n2) {
 25        if (n1 % k == 0 && n2 % k == 0)
 26          gcd = k; // Update gcd
 27        k++;
 28      }
 29  
 30      return gcd; // Return gcd
 31    }
 32  }