Python-Sieve of Eratosthenes (24ms)
```\nclass Solution:\n    def numPrimeArrangements(self, n: int) -> int:\n        def fact(n):\n            if n==0 or n==1:\n                return 1\n        
```\nclass Solution:\n    def numPrimeArrangements(self, n: int) -> int:\n        def fact(n):\n            if n==0 or n==1:\n                return 1\n            else:\n                return n*fact(n-1)\n        prime=[True]*(n+1)\n        for i in range(2,math.ceil(math.sqrt(n))+1):\n            if prime[i]:\n                for j in range(i*i,n+1,i):\n                    prime[j]=False\n        summ=sum(prime)-2\n        return fact(n-summ)*fact(summ)%(10**9+7)\n        \n
[]