1 class Solution: 2 def factorial(self,N): 3 result = 1 4 while N > 0: 5 result *= N 6 N -= 1 7 return result 8 9 def numPrimeArrangements(self, n: int) -> int: 10 primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97} 11 pcount = 0 12 for i in range(1,n+1): 13 if i in primes: 14 pcount += 1 15 count = self.factorial(pcount) * self.factorial(n-pcount) 16 17 return count % 1000000007