Created
August 22, 2018 13:50
-
-
Save TerryZ/05fec2a75912e55dcad71a723420f843 to your computer and use it in GitHub Desktop.
最小公约数计算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gcd(a,b){ | |
var minNum = Math.min(a,b),maxNum = Math.max(a,b),i=minNum,vper=0; | |
if(a ===0 || b===0) return maxNum; | |
for(var i=1;i<=maxNum;i++){ | |
vper = minNum * i; | |
if(vper % maxNum === 0){ | |
return vper; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment