Easy Understandable Solution | Beats 100% | Brute Force
\n\n# Code\n\nclass Solution {\n    public int numPrimeArrangements(int n) {\n        int numPrime=countPrime(n);\n        int numComposite=n-numPrime;\n\n     
\n\n# Code\n```\nclass Solution {\n    public int numPrimeArrangements(int n) {\n        int numPrime=countPrime(n);\n        int numComposite=n-numPrime;\n\n        long primePermu=permutation(numPrime);\n        long compositePermu=permutation(numComposite);\n\n        long result= (primePermu*compositePermu)%(long)(Math.pow(10,9)+7);\n        return (int)result;\n    }\n    public int countPrime(int n){\n        int count=0;\n        for(int i=2;i<=n;i++){\n            int flag=1;\n            for(int j=2;j<=Math.sqrt(i);j++){\n                if(i%j==0){\n                    flag=0;\n                    break;\n                }\n            }\n            if(flag==1){\n                count++;\n            }\n        }\n        return count;\n    }\n    public long permutation(int num){\n        long pro=1;\n        for(int i=num;i>=1;i--){\n            pro=(pro*i)%(long)(Math.pow(10,9)+7);\n        }\n        return pro;\n    }\n}\n```
['Java']