Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

复习大学算法课 #44

Open
taikulawo opened this issue Apr 26, 2020 · 0 comments
Open

复习大学算法课 #44

taikulawo opened this issue Apr 26, 2020 · 0 comments

Comments

@taikulawo
Copy link
Collaborator

挺多东西时间长了不接触都忘记了

10÷6=1...4
10是被除数,6是除数,1是商,4是余数

4 == 10 % 6

两数相除,除数变被除数,余数变除数

设余数为x

                n
                 ----> x
       m % n =
                     -> n
       <-----------x
!function() {
   const log = console.log
   function gcd(m,n) {
       while(n > 0){
           let x = n
           n = m % n
           m = x
       }
       return m
   }
   log(gcd(12,16))
}()
@taikulawo taikulawo changed the title 辗转相除法求最大公约数 复习大学算法课 Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant