package leetcode;

/**
 * https://leetcode.com/problems/prime-arrangements/
 */
public class Problem1175 {
    public int numPrimeArrangements(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1175 prob = new Problem1175();
        System.out.println(prob.numPrimeArrangements(5)); // 12
        System.out.println(prob.numPrimeArrangements(100)); // 682289015
    }
}

@@ -157,82 +157,206 @@
     
-// TODO%0A        return 0;
+boolean%5B%5D primes = new boolean%5Bn + 1%5D;%0A        for (int i = 2; i %3C primes.length; i++) %7B
 %0A    
-%7D%0A%0A
+    
     p
-ublic static void main(String%5B%5D args
+rimes%5Bi%5D = true;%0A        %7D%0A        for (int i = 2; i * i %3C= n; i++) %7B%0A            if (!primes%5Bi%5D
 ) %7B%0A
@@ -367,182 +367,586 @@
     
+  
-Problem1175 prob = new Problem1175();%0A        System.out.println(prob.numPrimeArrangements(5)); // 12
+      continue;%0A            %7D%0A            for (int j = i * i; j %3C= n; j += i) %7B%0A                primes%5Bj%5D = false;%0A            %7D%0A        %7D%0A        int count = 0;%0A        for (int i = 2; i %3C primes.length; i++) %7B%0A            if (primes%5Bi%5D) %7B%0A                count++;%0A            %7D%0A        %7D%0A        return (int) ((factorial(count) * factorial(n - count)) %25 1000000007);
 %0A    
+%7D%0A%0A
     
-System.out.println(prob.numPrimeArrangements(100)); // 682289015
+private static long factorial(int n) %7B%0A        long result = 1;%0A        for (int i = 2; i %3C= n; i++) %7B%0A            result = (result * i) %25 1000000007;%0A        %7D%0A        return result %25 1000000007;
 %0A   

Solve problem 1175