Numbers on the blackboard There's a list of $N$ natural numbers on the blackboard. At one step you can pick any two number, which do not divide each other. Instead of this pairs you write its gcd and lcm. 
Problem asks to prove that final result doesn't depend on order on which this operation applied. I guess to prove the operation is associative.
$$(4, 6, 9) \rightarrow\ (2, 12, 9) \rightarrow \ (2, 3, 36) \rightarrow \ (1, 6, 36)$$
$$(4, 6, 9)\  \rightarrow\ (4, 3, 18)\  \rightarrow\ (1, 12, 18) \rightarrow\ (1, 6, 36)$$
I figure that in the head and tail of final result list contains gcd and lcd of the whole list. However, what's going in between I didn't. 
 A: The operations $\gcd$ and $\def\lcm{\operatorname{lcm}}\lcm$ can be represented as the operations $\min$ and $\max$, respectively, on the exponents in the prime factorizations:
$$
\gcd\left(\prod_ip_i^{a_i},\prod_ip_i^{b_i}\right)=\prod_ip_i^{\min(a_i,b_i)}\;,\\
\lcm\left(\prod_ip_i^{a_i},\prod_ip_i^{b_i}\right)=\prod_ip_i^{\max(a_i,b_i)}\;.
$$
When you apply $\gcd$ and $\lcm$ to two numbers, for each prime you put the lesser exponent in the $\gcd$ and the greater exponent in the $\lcm$. You still have the same exponents; they just get sorted into lesser and greater ones. By defining a suitable sorting measure, e.g. $\left|\sum_i(a_i-b_i)\right|$ summed over all pairs of numbers, and noting that it increases in every step and is bounded from above, you can show that the process terminates. Clearly it can only terminate if a total order has been reached, where for any two pairs one contains all the lesser exponents and the other all the greater exponents. It follows that when the numbers are arranged in this order, the exponents for each prime are also arranged in this order. This determines the exponents, and hence the numbers, and it follows that the terminal state is independent of the order of operations.
Thanks to Carl for suggesting this approach.
P.S.: To make this a bit more concrete, we can represent the numbers $4,6,9$ in your example by their exponents for the two primes $2$ and $3$ that occur in them. Then we start out with $(2,0)$, $(1,1)$ and $(0,2)$. Sorting the exponents in the first component yields $0,1,2$, and likewise for the second component, so the terminal vectors are $(0,0)$, $(1,1)$ and $(2,2)$, corresponding to $1,6,36$.
A: Neat problem. I don't have a complete solution, but I think a productive area would be to look at the prime factorizations of the numbers and see what happens to the exponents.
$$(2^2\cdot3^0, 2^1\cdot3^1, 2^0\cdot 3^2)$$
$$\to (2^1\cdot3^0, 2^2\cdot 3^1, 2^0\cdot3^2) \to (2^1\cdot3^0, 2^0\cdot3^1, 2^2\cdot 3^2) \to$$
or
$$\to(2^2\cdot3^0, 2^0\cdot3^1, 2^1\cdot3^2) \to(2^0\cdot3^0, 2^2\cdot 3^1, 2^1\cdot3^2) \to$$
$$(2^0\cdot3^0, 2^1\cdot3^1, 2^2\cdot 3^2)$$
In the first case the powers of 2 are $(2^2,2^1,2^0)$, which get transformed into $(2^1,2^2,2^0)$ and then $(2^1,2^0,2^2)$ before ending up as $(2^0,2^1,2^2)$. In the second case $(2^2,2^1,2^0)$ becomes $(2^2,2^0,2^1)$ and then $(2^0,2^2,2^1)$ before ending up as $(2^0,2^1,2^2)$. The exponents appear to be sorting themselves. The same thing happens to the powers of 3, and would happen to the powers of any other primes.
(Sorry this isn't a complete proof, but it looks like it could lead to one.)
A: Note that in the configuration at the end, for each pair of numbers one is the least common multiple of the two and the other is the greatest common divisor (otherwise you get a different list). So the higher is an integer multiple of the lower.
Organise the numbers in ascending order - you get $d, a_1d, a_1a_2d \dots$
Now notice that if you drop the first element (or the last, or in fact any of them) the same property remains. Drop $d$ and divide through by $d$. Then $a_1$ is the hcf of what remains (etc).
A: As you say, you are proving that $f: \langle x,y \rangle \mapsto \langle \text{gcd}(x,y), \text{lcm}(x, y) \rangle$ is associative.
I'll write $g: \mathbb{N}^n \to \mathbb{N}$ for the GCD function, and $l: \mathbb{N}^n \to \mathbb{N}$ for the LCM, using the handy convention of $g(a,b,c)$ for $g(g(a,b),c)$ etc - justified by the next paragraph.
I claim first that $g$ is associative. Indeed, that's obvious just by considering the prime factorisations of the inputs. Likewise $l$, although you could prove this by using $l(x, y) = \frac{x y}{g(x, y)}$.
Now, I claim that $g(l(x, y), z) = l(g(x,z), g(y, z))$. This again follows by considering the prime factorisations.
Therefore, it is possible in any expression of the form "sequence of LCMs and GCDs" to pull out all the LCM terms to the front. Moreover, the resulting expression is precisely of the form $l( g(a,b,\dots), g(c,d,\dots), \dots)$ with no further levels of nesting. We just need to prove that the structure is the same however we apply the operations.
In your example, {4, 6, 9}, we find {g(4, 6), l(4, 6), 9}, then {g(4, 6), g(l(4, 6), 9), l(l(4, 6), 9)} which is $$\{g(4, 6), l(g(4, 9), g(6, 9)), l(4, 6, 9)\}$$
Finally, $\{g(g(4,6), l(g(4,9),g(6,9))), l(g(4,6), l(g(4,9),g(6,9))), l(4,6,9)\}$ which is $$\{g(4, 6, 9), l(g(4,6), g(4,9), g(6,9)), l(4,6,9)\}$$
This is manifestly symmetric, so it can't matter which order we took the operations in to get there.
I didn't rely on any special properties of 4, 6, 9: they stand in for general $a, b, c$. It's clear, by the way, that we need to stop the procedure here, because $g(a,b,c)$ divides $l(g(a,b),g(b,c),g(a,c))$ which divides $l(a,b,c)$.
This generalises, messily, by induction.
A: The operation doesn't change the product of the numbers. Since you've figured out what two of the numbers of the final result will be, you can solve for the remaining one.
