[Accepted] Swift
\nclass Solution {\n    func numPrimeArrangements(_ n: Int) -> Int {\n        \n        func p(_ x: Int) -> Bool {\n            guard x > 1 else { return false 
```\nclass Solution {\n    func numPrimeArrangements(_ n: Int) -> Int {\n        \n        func p(_ x: Int) -> Bool {\n            guard x > 1 else { return false }\n            guard x > 3 else { return true }\n            return (2...(x / 2)).allSatisfy { x % $0 != 0 }\n        }\n        \n        func f(_ x: Int) -> Int {\n            guard x > 0 else { return 1 }\n            return (1...x).reduce(into: 1) { $0 = ($0 * $1) % 1000000007 }\n        }\n        \n        let pc = (1...n).filter(p).count\n        let nc = n - pc\n        \n        return f(pc) * f(nc) % 1000000007\n    }\n}\n```
['Swift']