Prime Arrangements Problem
Prime Arrangements Problem — ExecCode Easy DSA Practice
Solve the Prime Arrangements problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the input needed to solve Prime Arrangements. Your task is to compute the required answer and return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.). (Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.) Since the answer may be large, return the answer modulo 10^9 + 7 .
Examples
Input {"n": 5}; Output 12. Input {"n": 100}; Output 682289015
Constraints
1 <= n <= 100
Practice Prime Arrangements free on ExecCode. Browse DSA problems, topic map, and placement guides.