Easiest cpp solution || sieve algo ||permutation combination
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nloglogn)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\no(n)\n# Code\n```\nclass Solution {\npublic:\n    int numPrimeArrangements(int n) {\n        bool prime[n+1];\n        memset(prime,true,sizeof(prime));\n        prime[0]=prime[1]=false;\n        for(int i=2;i*i<=n;i++){\n            if(prime[i]){\n                for(int j=i*2;j<=n;j+=i){\n                  prime[j]=false;\n                }\n            }\n        }\n        int cnt=0,cnt1=0;;\n        for(int i=1;i<=n;i++){\n            if(prime[i]){\n                cnt++;\n            }else{\n                cnt1++;\n            }\n        }\n        long long ans=1,k=1e9+7;\n        for(int i=cnt;i>1;i--){\n          ans=(ans*i)%k;\n        }\n        for(int i=cnt1;i>1;i--){\n          ans=(ans*i)%k;\n        }\n        return ans;\n    }\n};\n```
['C++']