C++ | 100% Fast 0ms Simple Solution
\nint M = pow(10, 9) + 7;\nclass Solution {\npublic:\n    int numPrimeArrangements(int n) {\n        \n        vector<bool> seive(n + 1, true);\n        seive[1
```\nint M = pow(10, 9) + 7;\nclass Solution {\npublic:\n    int numPrimeArrangements(int n) {\n        \n        vector<bool> seive(n + 1, true);\n        seive[1] = false;\n        int no_of_primes = 0;\n        for(int i = 2; i <= n; i++)\n            if(seive[i])\n            {\n                no_of_primes++;\n                int tmp = 2;\n                while(tmp * i <= n)\n                    seive[tmp * i] = false, tmp++;\n            }\n        \n        long long ans = 1;\n        for(int i = 1; i <= no_of_primes; i++)\n            ans = (ans * i) % M;\n        \n        for(int i = 1; i <= n - no_of_primes; i++)\n            ans = (ans * i) % M;\n            \n        return ans;\n    }\n};\n```
['C']