It seems to run - I enter 2 lines on the keyboard and if they are not positive integers, an Exception is thrown - otherwise the GCD is displayed.
I am really stuck on this - did I misunderstand the requirements?

package com.codegym.task.task14.task1420;
/*
GCD
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String one = reader.readLine();
String two = reader.readLine();
int input1 = Integer.parseInt(one);
int input2 = Integer.parseInt(two);
if(input1 > 0 && input2 > 0){ printGCD(input1, input2);}
else{throw new NumberFormatException("Number needs to be positive");}
}
public static void printGCD(int input1, int input2) {
int a = 0;
int b = 0;
if (input1 > input2) {
a = input1;
b = input2;
} else if (input2 > input1) {
a = input1;
b = input2;
}
int rest = 0;
while (true) {
rest = a % b;
if (rest == 0) {
System.out.println(b);
break;
} else if (rest > 0) {
a = b;
b = rest;
}
}
}
}

and only oneof the operands istrue. So: false ^ false = false true ^ false = true true ^ true = false Booleans have two values, true or false Bits have two values, 1 or 0 The logical operators work on bits the same exact way as they work on booleans, just think of0 as falseand1 as trueSo, with the above code, its best to show how it works with an example. Take these two numbers: 6 and 13 - the binary of 6 is 0110 we will call thisvar1- the binary of 13 is 1101 we will call thisvar2-Step one dovar1 = var1(0110) ^ var2(1101)0110 1101 ¯¯¯¯ 1011 = var1 - step 2 dovar2 = var1(1011) ^ var2(1101)1011 1101 ¯¯¯¯ 0110 = var2 step 3 dovar1 = var1(1011) ^ var2(0110)1011 0110 ¯¯¯¯ 1101 = var1 So you are left withvar1 equal to 1101andvar2 equal to 0110, which are the binary for 13 and 6, so the values have been swapped. Walk through the steps a couple of times, they work.