// Not using conditional operator: int gcd(int x, int y) { // Setup your vars: int z; int retVal = -1; // Figure out which is higher: if (x > y) z = x else z = y; // Run the for loop: // for (set the value; while this is true keep going; do this every iteration) for (i = z; i > 0; i--) { if (x % i == 0 && y % i == 0) { // Set retVal to the i and i to 0 which ends the loop retVal = i; i = 0; } } return retVal; } // Using conditional operator: int gcd(int x, int y) { // Setup your vars: int retVal = -1; // Figure out which is higher: // Conditional z equals x if (x > y) otherwise it equals y; z = (x > y)?x:y; // Run the for loop: // for (set the value; while this is true keep going; do this every iteration) for (i = z; i > 0; i--) { if (x % i == 0 && y % i == 0) { // Set retVal to the i and i to 0 which ends the loop retVal = i; i = 0; } } return retVal; }