O(n) time, O(1) space
\npublic class Solution {\n    static readonly int modulo = 1_000_000_007;\n    static readonly int[] primes = new int[] {\n        2, 3, 5, 7, 11, 13, 17, 19, 
```\npublic class Solution {\n    static readonly int modulo = 1_000_000_007;\n    static readonly int[] primes = new int[] {\n        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, \n        43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 \n    };\n    public int NumPrimeArrangements(int n) {\n        var p = 0;\n        long res = 1;\n        for(; p < primes.Length && primes[p] <= n; ++p) {}\n        for(int i = n - p; 0 < i; --i) {\n            res = (res*i) % modulo;\n        }\n        for(int i = p; 0 < i; --i) {\n            res = (res*i) % modulo;\n        }\n        return (int)res;\n    }\n}\n```
[]