import fractions
from functools import reduce
i = 200
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
      
ans = 0
for i1 in range(1,i+1):
    for i2 in range(1,i+1):
        for i3 in range(1,i+1):
            num = gcd(i1,i2,i3)
            ans += num
print(ans)