Given you $n,x,k$ , find the value of the following formula:
$$
\sum_{a_1=1}^{n}\sum_{a_2=1}^{n}\ldots \sum_{a_x=1}^{n}\left (\prod_{j=1}^{x}a_j^k\right )f(\gcd(a_1,a_2,\ldots ,a_x))\cdot \gcd(a_1,a_2,\ldots ,a_x)
$$
$\gcd(a_1,a_2,\ldots ,a_n)$ is the greatest common divisor of $a_1,a_2,...,a_n$.
The function $f(x)$ is defined as follows:
If there exists an ingeter $k\ (k>1)$ , and $k^2$ is a divisor of $x$,
then $f(x)=0$, else $f(x)=1$.