思路:
代码实现:
public class Main3 {
public static void main(String[] args) {
long time = System.nanoTime();
int a = 2019;
int b = 324;
int count =0 ;
boolean bool = true;
while(bool) {
if (a >b) {
a = a-b;
count ++ ;
}else if (a<b) {
b = b-a;
count++;
}else if (a == b && a!=0 ) {
a = a -b;
count ++;
bool = false;//退出
}
}
System.out.println(count);
long time2 = System.nanoTime();
System.out.println(time2 - time);
}
}
文章评论