Practice Prime Arrangements
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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.
Source: Prime Arrangements on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 5
Output
12
# Example 2
Input
n = 100
Output
682289015
Constraints
1 <= n <= 100
Related LeetCode Problems
Practice more problems similar to Prime Arrangements.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.