import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    } main {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k); divisors new ArrayList<>(k) for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        } int i = 1 ; int i = 1 ; i 1 i <= k i k i++ i++ i {
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        } {
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        } ArrayList<Integer> divs = new ArrayList<>(); divs new ArrayList<>() for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            } int j = k ; int j = k ; j k j >= 1 j 1 j-- j-- j {
                if((i % j) == 0){
                    divs.add(j);
                }
            } {
                if((i % j) == 0){
                    divs.add(j);
                }
            } if((i % j) == 0){
                    divs.add(j);
                } (i % j) == 0 (i % j) i j 0 {
                    divs.add(j);
                } divs.add(j) divs.add divs j divisors.add(divs) divisors.add divisors divs long sum = 0; sum 0 for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        } int i = 1 ; int i = 1 ; i 1 i <= k i k i++ i++ i {
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        } {
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        } for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            } int j = 1 ; int j = 1 ; j 1 j <= k j k j++ j++ j {
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            } {
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            } for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                } int l = 1 ; int l = 1 ; l 1 l <= k l k l++ l++ l {
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                } {
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                } int m = Math.min(Math.min(i,j),l); m Math.min(Math.min(i,j),l) Math.min Math Math.min(i,j) Math.min Math i j l for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    } int d divisors.get(m-1) divisors.get divisors m-1 m 1 {
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    } {
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    } if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        } (i % d) == 0 && (j % d) == 0 && (l % d) == 0 (i % d) == 0 && (j % d) == 0 && (l % d) == 0 (i % d) == 0 (i % d) i d 0 (j % d) == 0 (j % d) j d 0 (l % d) == 0 (l % d) l d 0 {
                            sum += d;
                            break;
                        } sum += d sum d break; System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
}
