Mersenne Composite Numbers
Time limit1sMemory limit128 MB
Factor every composite Mersenne number 2^P - 1 for prime P up to K and print the factorizations in increasing order.
- Level
Medium7 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
A Mersenne number is a number of the form , where is prime.
While stays small, every Mersenne number looks prime.
Once is a large enough prime, however, can fail to be prime. Call a Mersenne number that is not prime a Mersenne composite.
Given an integer , write a program that finds every Mersenne composite with and factors it into primes.
Input
The input has a single integer . ()
Output
Print the prime factorization of every Mersenne composite with , one per line. Each line has this shape.
q1 * q2 * ... * qm = M = ( 2 ^ P ) - 1
Here and are the prime factors of in ascending order. A prime that divides several times is written that many times. Keep the spacing around the symbols exactly as shown.
Order the lines by the Mersenne composite itself, smallest first. If no such number exists, print nothing.