如何用 Java 编写这段代码?
def gcd(a, b):
"""
Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
"""
while b:
a, b = b, a%b
return a
while (b) {
由于Type mismatch
错误,我似乎无法在 Java 中执行此操作。看来我也不能a, b = b, a%b
完全用Java做这条线。