Prime Arrangement-Sieve of erotosthenes
\nclass Solution {\n     long mod = (long)(1e9+7);\n    public int numPrimeArrangements(int n) {\n        if(n==1){\n            return 1;\n        }\n     \n  
```\nclass Solution {\n     long mod = (long)(1e9+7);\n    public int numPrimeArrangements(int n) {\n        if(n==1){\n            return 1;\n        }\n     \n        boolean[] arr = new boolean[n+1];\n        Arrays.fill(arr,true);\n        arr[0]=false;\n        arr[1]=false;\n        \n        for(int i=2;i<=Math.sqrt(n);i++){\n            \n            for(int j=i*i;j<=n;j+=i){\n                if(arr[i]==false){\n                    continue;\n                }\n                arr[j]=false;\n            }\n            \n        }\n       long prime = 0;\n        long notPrime=0;\n        for(int k=1;k<arr.length;k++){\n            if(arr[k]==true){\n                prime++;\n            }\n            else{\n                notPrime++;\n            }\n        }\n\n       long x = factorial(prime)%mod;\n       long y = factorial(notPrime)%mod;\n       long t = (x*y)%mod;\n        return (int)t ;\n        \n    }\n \n    public long factorial(long i){\n        if(i<=1){\n            return i;\n        }\n        return (i*(factorial(i-1)%mod))%mod;\n    }\n}\n```\nIf you find helpful please upvote.
['Java']