The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.


The counterpart to the least common multiple is the greatest common divisor (gcd). The greatest common divisor of two natural numbers a and b is the largest natural numbers that divides a and b.


Write a function gcd that takes two natural numbers and calculates their gcd.

Example: gcd(6, 15) should return 3.