<p>Return the number of permutations of 1 to <code>n</code> so that prime numbers are at prime indices (1-indexed.)</p>

<p><em>(Recall that an integer&nbsp;is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers&nbsp;both smaller than it.)</em></p>

<p>Since the answer may be large, return the answer <strong>modulo <code>10^9 + 7</code></strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 5
<strong>Output:</strong> 12
<strong>Explanation:</strong> For example [1,2,5,4,3] is a valid permutation, but [5,2,3,4,1] is not because the prime number 5 is at index 1.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 100
<strong>Output:</strong> 682289015
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 100</code></li>
</ul>

class Solution:

    def check_prime(self, num: int) -> int:
        """
        Return 1 if it's a prime. Else, return 0
        """
        if num == 1:
            return 0
        if num == 2:
            return 1 # prime
        if num % 2 == 0:
            return 0
        for i in range(2, (num//2)+1): # prime number has to be odd
            if (num % i) == 0:
                return 0
        return 1

    def numPrimeArrangements(self, n: int) -> int:
        # count how many prime number
        count = 0
        for i in range(1, n+1):
            count +=self.check_prime(i)
        # return count
        return math.factorial(count) * math.factorial(n - count) % (10**9 + 7)
        
25