#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int gcd(int a, int b, int c){
    int r, temp;
    if(a<b){
        temp = a;
        a = b;
        b = temp;
    }

    // Euclidean Algorithm 
    r = a%b;
    while(r != 0){
        a = b;
        b = r;
        r = a%b;
    }

	    if(c<b){
        temp = c;
        c = b;
        b = temp;
    }

    // Euclidean Algorithm 
    r = c%b;
    while(r != 0){
        c = b;
        b = r;
        r = c%b;
    }
    return b;
}


int main(void){
	int n;
	scanf("%d",&n);
	long long sigma=0;
	int i, j, k;
	int a;
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++){
			for(k=j;k<=n;k++){
				if(i==j&&j==k){
					a = 1;
				}
				else if(i!=j && j!=k && k!=i){
					a = 6;
				}
				else{
					a = 3;
				}
				sigma += a*gcd(i,j,k);
				printf("%lld\n",sigma);
			}
		}
	} 
	printf("%lld\n",sigma);
    return 0; 
}
