Port of Fischer-Krause algorithm to Java