Can some one find here error? I am getting all correct except passing all condition ?
package com.codegym.task.task14.task1420;
/*
GCD
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
int numOne = Integer.parseInt(reader.readLine());
int numTwo = Integer.parseInt(reader.readLine());
int remainderOne = numOne % 2;
int remainderTwo = numTwo % 2;
if ((remainderOne != 0 || numOne < 0) || (remainderTwo != 0 || numTwo < 0)) {
throw new NumberFormatException();
}
System.out.println(gdc(numOne, numTwo));
}catch (NumberFormatException e) {
System.out.println("Wrong input");
}
}
public static int gdc ( int numOne, int numTwo){
int startingGDC = numOne > numTwo ? numTwo : numOne;
int maxGDC = 0;
if (numOne == 0) {
return maxGDC = numTwo;
} else if (numTwo == 0) {
return maxGDC = numOne;
} else {
for (int i = startingGDC; i > 0; i--) {
double gdcOneDOUBLE = (double) numOne / i;
int gdcOneINTEGER = numOne / i;
double gdcTwoDOUBLE = (double) numTwo / i;
int gdcTwoINTEGER = numTwo / i;
if (gdcOneDOUBLE == Math.floor(gdcOneINTEGER) && gdcTwoDOUBLE == Math.floor(gdcTwoINTEGER)) {
maxGDC = i;
return maxGDC;
}
}
}
return maxGDC;
}
}