public static double GCD(List<double> listOri)
{
    List<double> list = new List<double>(listOri);            

    double c = 1;           
    for (int i = 1; i < list.Count; i++)
    {
        if (list[i - 1] < list[i]) //确定a>b
        {
            list[i - 1] = list[i - 1] + list[i];
            list[i] = list[i - 1] - list[i];
            list[i - 1] = list[i - 1] - list[i];
        }
        for (c = list[i]; c >= 1; c--)
        {
            if (list[i - 1] % c == 0 && list[i] % c == 0)
                break;
        }
        list[i] = c;
    }
    return c;
}

 

相关文章:

  • 2022-01-03
  • 2021-09-01
  • 2021-08-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-05
  • 2022-12-23
  • 2021-04-23
  • 2021-08-01
相关资源
相似解决方案