3 ms·
Did you mean it's only fast when it's a small number, or does it fail at some point? EX: works for 10005^2 and 12345^2.
by onemoreact 15y ago
Did you mean it's only fast when it's a small number, or does it fail at some point?
EX: works for 10005^2 and 12345^2.
- lkozma 15y agoIt works for any number, I meant "reasonably small", because for those it can be done mentally.
- onemoreact 15y agoCool, thanks I was sitting there trying to think why it would fail for large numbers. But, (x * 10 + 5)^2 = x * x * 10 * 10 + 2 * x * 50 + 25 = x * (x + 1) * 100 + 2 .
- onemoreact 15y agoedit '+ 2 .' should be '+ 25.' so: (x * 10 + 5)^2 = x * x * 10 * 10 + 2 * x * 50 + 25 = x * (x + 1) * 100 + 25.