Concise JS Solution
\nvar numPrimeArrangements = function(n) {\n    const mod = 10**9 + 7;\n    let primes = 0, nonPrimes = 0;\n    let res = 1;\n    for (let i = 1; i <= n; i++) {
```\nvar numPrimeArrangements = function(n) {\n    const mod = 10**9 + 7;\n    let primes = 0, nonPrimes = 0;\n    let res = 1;\n    for (let i = 1; i <= n; i++) {\n        if (isPrime(i)) res *= ++primes;\n        else res *= ++nonPrimes;\n        res = res % mod;\n    }\n    return res;\n    // Time Complexity: O(n^(3/2))\n    // Space Complexity: O(1)\n};\n\nvar isPrime = function(n) {\n    if (n <= 1) return false;\n    if (n <= 3) return true;\n    let i = 2;\n    while (i <= Math.sqrt(n)) {\n        if (n % i == 0) return false;\n        i++;\n    }\n    return true;\n}\n```
['JavaScript']