Java Solution   ( PrimeCount ! )  *  (NonPrimeCount !)
\nclass Solution {\n    public int numPrimeArrangements(int n) {\n        if(n <= 2) {\n            return 1;\n        }\n        int count = countPrime(n);\n  
```\nclass Solution {\n    public int numPrimeArrangements(int n) {\n        if(n <= 2) {\n            return 1;\n        }\n        int count = countPrime(n);\n        long sum = 1;\n        for(int i = 2; i <= count; i++) {\n            sum = (sum * i) % 1000000007;\n        }\n        for(int i = n - count; i >= 2; i--) {\n            sum = (sum * i) % 1000000007;\n        } \n        return (int)(sum % 1000000007);\n    }\n\n    private int countPrime(int n) {\n        int count = 0;\n        boolean[] v = new boolean[n + 1]; \n        for(int i = 2; i * i <= n; i++) {\n            for(int j = 2; j * i <= n; j++) {\n                v[i * j] = true;\n            }\n        }\n        for(int i = 2; i <= n; i++) {\n            if(!v[i] && isPrime(i)) {\n                count++;\n            }\n        }\n        return count;\n    }\n    \n    private boolean isPrime(int val) {\n        for(int i = 2; i * i <= val; i++) {\n            if(val % i == 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```
[]