#include <stdio.h>
int main(void){
    int K, a, b = 0, c, x = 0, RM, M;
    scanf("%d", &K);
    a = K / 2;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                M = (i > j)? i : j;
                RM = (k > M)? k : M;
                for(int l = 1; l <= M; l++){
                    if(i % l == 0)
                        if(j % l == 0)
                            if(k % l == 0){
                                c = l;
                                if(b < c) b = c;
                            }
                }
                x += b;
                b = 0;
            }
        }
    }
    printf("%d\n", x);
  return 0;
}