• + 1 comment

    move that n-d outside the loop its always same. other then that your solution is best.