#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int map1[201][201];
int gcd(int a,int b){
	if (a>b){
		int c=a;
		a=b,b=c;
	}
	if (map1[a][b])return map1[a][b];
	int x=a,y=b;
	while (a%b){
		int c=a%b;
		a=b;
		b=c;
	}
	map1[x][y]=b;
	return b;
}
int main(){
	n=200;
	long long sum=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			for (int k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

