Python 3 + Mathematical Solution + Sieve Method
class Solution:\n    def numPrimeArrangements(self, n: int) -> int:\n\t\n        if n < 0:\n            return 0\n        flag = [1]n\n        for i in range(2,
class Solution:\n    def numPrimeArrangements(self, n: int) -> int:\n\t\n        if n < 0:\n            return 0\n        flag = [1]*n\n        for i in range(2, n+1):\n            for j in range(i*i, n+1, i):\n                flag[j-1] = 0\n        \n        prime_num = sum(flag)-1\n        return (self.factor(n-prime_num)*self.factor(prime_num))%(10**9 + 7)\n    \n    def factor(self, n):\n        res = 1\n        for i in range(n, 1, -1):\n            res *= i\n        return res\n
['Math', 'Python', 'Python3']