Advertisement
Guest User

Untitled

a guest
May 1st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. var Euclid = {};
  2.  
  3. Euclid.gcd = function greatestCommonDivisor( a, b) {
  4.  
  5. "use strict";
  6.  
  7. var lilNum, bigNum, modulo;
  8.  
  9. lilNum = Math.min( a, b);
  10. bigNum = Math.max( a, b);
  11.  
  12. modulo = bigNum % lilNum;
  13.  
  14. if (modulo !== 0) {
  15. return this.gcd(modulo, lilNum);
  16. }
  17. else {
  18. return lilNum;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement