Hello
I don't know why the 2th step not work
Someone can help me
package fr.codegym.task.task14.task1420;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/*
PGCD
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int firstValue = 0;
int secondValue = 0;
try {
firstValue = Integer.parseInt(reader.readLine());
secondValue = Integer.parseInt(reader.readLine());
} catch (NumberFormatException e) {
throw new NumberFormatException();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int tmp = 0;
// if firstValue > secondValue ==> permute values
if (firstValue > secondValue) {
tmp = firstValue;
firstValue = secondValue;
secondValue = tmp;
}
// firstValue < secondValue
System.out.println(getPgcd(firstValue, secondValue));
}
public static int getPgcd(int firstValue, int secondValue) {
int indice = 0;
if (firstValue % firstValue == 0) {
if (secondValue % firstValue == 0) {
return firstValue;
}
}
indice = firstValue;
while (indice > 0) {
if (firstValue % --indice == 0) {
if (secondValue % indice == 0) {
return indice;
}
}
}
return 1;
}
}