• 算法之【辗转相除法】


    辗转相除法用于求两个或以上的正整数的最大公约数。

    The Euclidean Algorithm is used to get the greatest common divisor.

    语言描述:求两个整数的最大公约数时,先让一个整数整除另一个整数,求得余数,再分别将刚才的除数和余数作为新的被除数和除数进行运算,依次循环直到余数为0时停止,此时的除数就是刚开始两个数的最大公因子。用已求出的公因数和第三个整数再经过一次辗转相除法就求得三个数的最大公因数,以此类推。

    DescriptionTo find the greatest common divisor of two integers, firstly let one integerdivided by the other integer, the remainder is obtained, then regard the divisorand remainder as a new dividend and divisor respectively, and calculate again, until the final remainder is zero. Now the divisor is just the wanted greatest common divisor. Then compute the number along with a third integer through Euclidean Algorithm to get the greatest common divisor of three, and so on. 

    C语言函数表达式:

    C language description:

    int fun(int a,int b) 

    {

       int t;

    while(b)

    {

               t = a%b;

               a = b;

               b = t;

    }

                   return a;

    }

  • 相关阅读:
    Ckeditor事件绑定
    Linux使用netstat命令查看并发连接数
    memcached 常用命令及使用说明
    Linux(Ubuntu)下面SecureCRT 完全破解
    Linux下用SCP无需输入密码传输文件
    Java的URL类(一)
    java编码与解码(一)
    IDEA破解
    linux查看日志文件命令
    springboot +mybatis 搭建完整项目
  • 原文地址:https://www.cnblogs.com/jinhengyu/p/7517110.html
Copyright © 2020-2023  润新知