I have been reading through a programming book and the author asked to calculate the following expression in the program.
$$4*5^3+6*5^2+7*5+8$$
I approached this by expanding the expression like so:
$$(4*5*5*5)+(6*5*5)+(7*5)+8$$ $$500+150+35+8 = 693$$
In his solution he states that the expression can be rewritten as:
$$((4*5+6)*5+7)*5+8$$ $$(26*5+7)*5+8$$ $$(130+7)*5+8$$ $$(137*5)+8$$ $$685+8 = 693$$
Which produces the correct answer, but there is no explanation as to why this works. I wasn't aware the expression could be rewritten like this and the only pattern I can see is that the five to the power of x is decreasing by one each time.
Is there a technical name for this rule? I am curious to know why this works.