n seats numbered 1 to n, and there are n guests numbered 1 to n. Every guest gets one seat, so that a guest with a prime number sits in a seat with a prime number, and a guest with a non-prime number sits in a seat with a non-prime number.
Recall that a prime is greater than 1 and divisible only by 1 and itself; 1 is not prime.
Return the number of such seatings. It can be huge, so return it modulo 10⁹ + 7.n=4 → 4
The prime seats are 2 and 3. Guests 2 and 3 can take them in 2 ways, and guests 1 and 4 can take seats 1 and 4 in 2 ways: 2 · 2 = 4.
n=1 → 1
One guest and one seat give exactly one seating.
n=100 → 682289015
n=4
4
Run checks the first 3 tests in your browser. Submit checks all 30 tests on the server, hidden ones included.