Added faster algorithm, with no recursive limits.

Implemented an algorithm able to calculate diagonals instead.

Improved your implementation a little bit too (taken from wikipedia)