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

int main(void)
{
  long int i, j, k, l, n, result, sum = 0;
  
  scanf("%ld", &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 % j != 0 && i % k != 0 && j % i != 0 && j % k != 0 && k % i != 0 && k % j != 0 ){
            sum += 1;
            break;
          }*/
          
     	   if( i % l == 0 && j % l == 0 && k % l == 0 ){
          	result = l;
           }
          
          if( i <= l || j <= l || k <= l ){
            break;
          }
          
        }
        
        sum += result;
      }
    }
  }
 
  printf("%ld\n", sum);
  return 0;
}