Last active
August 29, 2015 14:05
-
-
Save zfdesign/55a75a19ae0611c6414a to your computer and use it in GitHub Desktop.
Task: write a function called GCD that prints the greatest common divisor of two positive integers (a and b).
This file contains hidden or 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
| /* Task: | |
| // Write a function called GCD | |
| // that prints the greatest common divisor of two positive integers (a and b). | |
| // */ | |
| function GCD(a,b) { | |
| 'use strict'; | |
| var calc = function (a,b) { | |
| return (a % b === 0) ? b : null; | |
| }, | |
| result = (a > b) ? calc(a,b) : calc(b,a); | |
| return result; | |
| } | |
| // GCD(32,128); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment