java 5 ms solution
Get the prime numbers between 1 to n. Then arrangement can be the product of factorial of prime numbers and non prime numbers.\n\nimport java.math.*;\nclass Sol
Get the prime numbers between 1 to n. Then arrangement can be the product of factorial of prime numbers and non prime numbers.\n```\nimport java.math.*;\nclass Solution {\n    \n    public BigInteger factorial(int k) {\n        if (k == 0) {\n            return  BigInteger.ONE;\n        }\n        return BigInteger.valueOf(k).multiply(factorial(k - 1));\n    }\n    \n    public BigInteger getModNumber(int n, int a) {\n        BigDecimal k = BigDecimal.valueOf(10.0);\n        k = k.pow(9).add(BigDecimal.valueOf(7.0));\n        return k.toBigInteger();\n    }\n    public int numPrimeArrangements(int n) {\n        int count = 0; \n        if (n == 1) {\n            return 1;\n        }\n        \n        for (int i = 2; i <= n; i++) {\n            int t = (int)Math.sqrt(i * 1.0);\n            int k = 0; \n            for (int j = 2; j <= t; j++) {\n                if (i % j == 0) {\n                    k++;\n                    break;\n                }\n               \n            }\n            if (k == 0) {\n                count++;\n            }\n        }\n        \n        BigInteger calc = factorial(count).multiply(factorial(n - count));\n        return calc.mod(getModNumber(9, 7)).intValue();\n    }\n}\n```
[]