100 % fast 0 ms java easy Solution
```\nclass Solution {\n    \n    boolean isPrime(int n){\n        if(n <= 1)\n            return false;\n        if(n <= 3)\n            return true;\n        i
```\nclass Solution {\n    \n    boolean isPrime(int n){\n        if(n <= 1)\n            return false;\n        if(n <= 3)\n            return true;\n        if(n % 2 == 0 || n % 3 == 0)\n            return false;\n        for(int i = 5; i * i <= n; i+=6){\n            if(n % i == 0 || n % (i+2) == 0)\n                return false;\n        }\n        return true;\n    }\n    \n    public int numPrimeArrangements(int n) {\n        \n        int primtCount = 0;\n        int mod = (int)(1e9+7);\n        \n        for(int i = 1; i <= n; i++)\n             if(isPrime(i))\n                 primtCount++;\n        \n        int nonPrime = n - primtCount;\n        long fact[] = new long[n+1];\n        fact[0] = 1;\n        \n        for(int i = 1; i <= n; i++){\n            fact[i] = (fact[i-1] * i) % mod;\n        }\n        \n        long ans = (fact[primtCount] * fact[nonPrime]) % mod;\n        return (int)ans;\n        \n    }\n}
[]