'Creating a Trace Table

I need to write a trace table which is supposed to look like this picture

Trace Table

To create the trace table I have to modify the following code with System.out.println commands, but I am not sure where to add them and how to get all 4 different columns.

I'd be super thankful for any help!

// ggT (x , y )                  // K1
while ( y != 0 ) {               // K2
   if ( x > y )                  // K3
     x = x - y ;                 // K4
   else
     y = y - x ;                 // K5
} 
System.out.println(x);           // K6


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source