ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
```java package net.zhaoxuyang.common.algorithm.math; /** * * @author zhaoxuyang */ public class Stein { public static void main(String[] args) { System.out.println(gcd(2412122241212121212L, 2131424432543544656L)); } static long gcd(long a, long b) { if (a == 0) { return b; } if (b == 0) { return a; } if (a % 2 == 0 && b % 2 == 0) { return 2 * gcd(a >> 1, b >> 1); } else if (a % 2 == 0) { return gcd(a >> 1, b); } else if (b % 2 == 0) { return gcd(a, b >> 1); } else { return gcd(Math.abs(a - b), Math.min(a, b)); } } } ```