您的位置:首页 > 其它

辗转相除 vs 递归(最大公约数)

2010-09-09 12:45 239 查看
  public int commondDivisor(int x,int y){

    int z;

    while(y != 0 ){

      z = x%y;

      x = y;

      y = z;

    }

    return x;

  }

  

  public int commondDivisor(int x,int y){

    int max = (y == 0) ? one : commondDivisor(y,x%y);

    return max;

  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: