We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- All Contests
- ProjectEuler+
- Project Euler #239: Twenty-two Foolish Primes
Project Euler #239: Twenty-two Foolish Primes
Project Euler #239: Twenty-two Foolish Primes
This problem is a programming version of Problem 239 from projecteuler.net
A set of disks numbered through are placed in a line in random order.
What is the probability that we have a partial derangement such that exactly prime number discs are found away from their natural positions? (Any number of non-prime disks may also be found in or out of their natural positions.)
It can be shown that for a given constraints the answer can be represented as , where and are coprime positive integers and . Print the value of modulo .
Input Format
The only line of input contains two integers and separated by single space.
Constraints
- where is number of primes in range from to inclusive.
Output Format
Print the only line with the answer.
Sample Input 0
10 3
Sample Output 0
498412760
Explanation 0
The actual value of is .