#include <stdio.h>

int main(void)
{
  int i, j, k, l, n, result, sum = 0;
  
  scanf("%d", &n);
  
  for( i = 1; i <= n; i++ ){
    for( j = 1; j <= n; j++ ){
      for( k = 1; k <= n; k++ ){
        result = 0;   
        for( l = 1; l <= n; l++ ){
          if( i < l || j < l || k < l ){
            break;
          }
     	   if( i % l == 0 && j % l == 0 && k % l == 0 ){
          	result = l;
           }
        }
        
        sum += result;
      }
    }
  }
 
  printf("%d\n", sum);
  return 0;
}