Provide an efficient algorithm that takes three integers as input and returns two integers that satisfy the condition. Only simple arithmetic operations are allowed (square root operation is not permitted).
Input: $(a, b, n)$ where $a, b, n$ are positive integers greater than $0$.
Output: $(c, d)$ where $c$ and $d$ are integers that satisfy the following condition: $$ (a + b \sqrt{3})^n = c + d \sqrt{3}$$
Thought it was an interesting problem, haven't come up with a solution yet.
Initially wanted to post the question in StackOverflow but I thought it was more math heavy.
This is similar to having multiplication in complex numbers $$(x+yi)(u+vi)=(xu-yv)+(xv+yu)i$$ Just instead of imaginary $i$ you have $\sqrt{3}$. So $$(x+y\sqrt{3})(u+v\sqrt{3})=(xu+3yv)+(xv+yu)\sqrt{3}$$ Now basically abstracting this idea to pairs of integers, you have $$(x,y)\cdot(u,v)=(xu+3yv,xv+yu)$$ Using this "$\cdot$" $n$ times correctly (actually $n-1$ times), you can calculate $n$-th power of a number. Notice that there are only basic arithmetic operations involved.
Efficience
Since you wanted also efficient algorithm, you can speed this up by using fast exponentiation. Basic idea is that instead of calculating $x$,$x^2$,$x^3$,etc, you just calculate \begin{align} x^2 &= x \cdot x \\ x^4 &= x^2 \cdot x^2 \\ x^8 &= x^4 \cdot x^4 \\ &\vdots \\ \end{align} and then combine the results correctly. This results on average in $\log_2{n}$ multiplication steps as compared to $n$ steps when using naive approach. There are other tricks to speed exponentiation up, suggest you to check them Fast exponentiation algorithm - How to arrive at it?, https://en.wikipedia.org/wiki/Exponentiation_by_squaring.
Algorithm Pseudocode
To be even more specific, lets construct one such algorithm. Let's pick for example this fast exponentiation algorithm:
Now replacing $x$ with pair of numbers $a,b$, and similarly the multiplication with the one described above, we get:
This by the way shows how you can calculate powers in general, you just need to have multiplication defined. Even in cases where it first looks like the problem is only solvable by recursions, this trick allows to skip many steps.
Python example
Now if you turn this into python (or any programming language you like), you can play with it:
For example
yields
And indeed, $(1+\sqrt{3})^{20} = 268377088+154947584\sqrt{3}$
Also notice there were only $5$ multiplications done, compared to naive $19$:
\begin{align} (1+\sqrt{3})^2 &= (1+\sqrt{3}) \cdot (1+\sqrt{3})\\ (1+\sqrt{3})^4 &= (1+\sqrt{3})^2 \cdot (1+\sqrt{3})^2\\ (1+\sqrt{3})^8 &= (1+\sqrt{3})^4 \cdot (1+\sqrt{3})^4\\ (1+\sqrt{3})^{16} &= (1+\sqrt{3})^8 \cdot (1+\sqrt{3})^8\\ (1+\sqrt{3})^{20} &= (1+\sqrt{3})^4 \cdot (1+\sqrt{3})^{16}\\ \end{align}