@Test public void gcdに784と840を渡すと56が帰ってくる() { long gcd = gcd(784, 840); assertThat(gcd, is(56L)); }
static long gcd(long num, long den) { long left, right; if (num < den) { left = den; right = num; } else { left = num; right = den; } Function<LongBiFunction, LongBiFunction> lf = f -> (l, r) -> r == 0? l : f.apply(r ,l % r); LongBiFunction fun = zComb(lf); return fun.apply(left, right); }
Fraction { static long gcd(long num, long den) { long left, right; if (num < den) { left = den; right = num; } else { left = num; right = den; } Function<LongBiFunction, LongBiFunction> lf = f -> (l, r) -> r == 0? l : f.apply(r ,l % r); LongBiFunction fun = zComb(lf); return fun.apply(left, right); } }
Fraction { static long gcd(long num, long den) { long left, right; if (num < den) { left = den; right = num; } else { left = num; right = den; } Function<LongBiFunction, LongBiFunction> lf = f -> (l, r) -> r == 0? l : f.apply(r ,l % r); LongBiFunction fun = zComb(lf); return fun.apply(left, right); } private  Fraction(long numerator); private  Fraction(long numerator, long denominator); }
Fraction { static long gcd(long num, long den) { long left, right; if (num < den) { left = den; right = num; } else { left = num; right = den; } Function<LongBiFunction, LongBiFunction> lf = f -> (l, r) -> r == 0? l : f.apply(r ,l % r); LongBiFunction fun = zComb(lf); return fun.apply(left, right); } private  Fraction(long numerator); private  Fraction(long numerator, long denominator); @Contract("_ -> !null") static Fraction fraction(long num); static Fraction fraction(long num, long den); @Contract(pure = true) long getSignedNumerator(); boolean isNegative(); @NotNull @Contract("_ -> !null") Fraction plus(long number); @NotNull @Contract("null -> fail") Fraction plus(Fraction fr); @Contract(pure = true) @Override String toString(); @Contract("null -> false") @Override boolean equals(Object o); @Override int hashCode(); }
Fraction { static long gcd(long num, long den) { long left, right; if (num < den) { left = den; right = num; } else { left = num; right = den; } Function<LongBiFunction, LongBiFunction> lf = f -> (l, r) -> r == 0? l : f.apply(r ,l % r); LongBiFunction fun = zComb(lf); return fun.apply(left, right); } private  Fraction(long numerator); private  Fraction(long numerator, long denominator); @Contract("_ -> !null") static Fraction fraction(long num); static Fraction fraction(long num, long den); @Contract(pure = true) long getSignedNumerator(); boolean isNegative(); @NotNull @Contract("_ -> !null") Fraction plus(long number); @NotNull @Contract("null -> fail") Fraction plus(Fraction fr); @Contract(pure = true) @Override String toString(); @Contract("null -> false") @Override boolean equals(Object o); @Override int hashCode();  }