Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's still a bit slower than it needs to be. The real trick to doing something like is seeing that we have 10(18x16) = 10(17^2 - 1) = 10(289-1)

Having the first 30 squares committed to memory has been pretty useful for me.



Right. And just to be explicit, we're using the fact that (x+1)(x-1) = x² -1. So to add in that step, it would be:

18 x 16 = (17+1)(17-1) = 10(17²-1)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: