#include <bits/stdc++.h>
using namespace std;

int main () {
  int N;
  cin >> N;
  long long ans = 0;
  for (int i = 1;i <= N; i++){
    for (int j = 1;j <= N; j++){
      for (int k = 1;k <= N; k++){
        int a = min (i, j);
        int b = min (a, k);
        for (int l = b; l >= 1; l--){
          bool plus = true;
          if (i%l != 0) plus = false;
          if (j%l != 0) plus = false;
          if (k%l != 0) plus = false;
          if (plus){
            ans += l;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}