Beats 100% in time and space, C++ code
\n# Code\n\nclass Solution {\npublic:\n    int numPrimeArrangements(int n) {\n        \n        int arr[100];\n        for (int i=0; i<100; i++) {\n            
\n# Code\n```\nclass Solution {\npublic:\n    int numPrimeArrangements(int n) {\n        \n        int arr[100];\n        for (int i=0; i<100; i++) {\n            arr[i] = 1;\n        }\n        arr[0] = 0;\n        for (int i=2; i*i<=100; i++) {\n            for (int j=i; j*i<=100; j++) {\n                arr[(i*j)-1] = 0;\n            }\n        }\n        for (int i=1; i<100; i++) {\n            arr[i] += arr[i-1];\n        }\n        long long int ans =1; int r = arr[n-1];\n        long long int req = 1e9 + 7;\n        for (int i=1; i<=r; i++) {\n            ans = (ans%req * i%req)%req;\n        }\n        for (int i=1; i<=(n-r); i++) {\n            ans = (ans%req * i%req)%req;\n        }\n        return ans;\n    }\n};\n```
['C++']