Python Simple Intuitive Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nFactorial comes into mind and then concept of number of prime numbers from [2, n] inclu
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFactorial comes into mind and then concept of number of prime numbers from [2, n] inclusive is to be dealt with. Remember 1 is not prime.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nDefine an isPrime() function that tells whether an input (y) is prime or not.\nRun a for loop from 1 to n+1 and count how many primes are there.\nDefine a Factorial function to calculate x!\nNow we know that prime indexes can be arranged in c! ways so we use fac(c) and also rest of the indices i.e. n-c can be arranged in (n-c)!\nways so we use fac() to calculate these factorials and our final answer will be given after modulo operation with (10**9+7)\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(n**2) due to isPrime() function\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1) due to the variable c.\n\n# Code\n```\nclass Solution:\n    def numPrimeArrangements(self, n: int) -> int:\n        def isPrime(y):\n            if y == 1:\n                return False\n            for i in range(2, y//2+1):\n                if y%i==0:\n                    return False\n            return True\n        c = 0\n        for i in range(1, n+1):\n            if isPrime(i) == True:\n                c+=1\n        def fac(x):\n            f = 1\n            while x > 0:\n                f = (f*x)%(10**9+7)\n                x-=1\n            return f\n        return fac(n-c)*fac(c)%(10**9+7)\n```
['Python3']