# Efficient algorithm to expand $(x+a)^n$

im looking for efficient algorithm to expand $(x+a)^n$ without using binomial theorem

is the repeating square method efficient for that problem with the help of binary representation of n ?

• This is very easy to find out. Just do it and count the operations. – gnasher729 Nov 26 '16 at 13:35
• Can you edit your question to clarify what you are asking? What counts as "expanding $(x+a)^n$"? What are the inputs, and what is the desired output? Do you mean, given numbers $x,a,n$, you want to compute the value of $(x+a)^n$? Or do you mean that, given the number $n$, you want to compute a symbolic expression for $(x+a)^n$, e.g., outputting a string like x^n + n * a * x^(n-1) + ... with the ... filled in appropriately? – D.W. Nov 26 '16 at 18:19