':type N: int
:rtype: int'

def countArrangement(self, N):

    def countArrangementHelper(n, arrangement):
        if (n <= 0):
            return 1
        count = 0
        for i in xrange(n):
            if (((arrangement[i] % n) == 0) or ((n % arrangement[i]) == 0)):
                (arrangement[i], arrangement[(n - 1)]) = (arrangement[(n - 1)], arrangement[i])
                count += countArrangementHelper((n - 1), arrangement)
                (arrangement[i], arrangement[(n - 1)]) = (arrangement[(n - 1)], arrangement[i])
        return count
    return countArrangementHelper(N, range(1, (N + 1)))
