This page is still under construction.

Parts of this page are still being built. What you see may change.

Mersenne Composite Numbers

Time limit1sMemory limit128 MB

Summary
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 2P−12^P - 1, where PP is prime.

While PP stays small, every Mersenne number looks prime.

Prime PPMersenne number 2P−12^P - 1
24−1=34 - 1 = 3, prime
38−1=78 - 1 = 7, prime
532−1=3132 - 1 = 31, prime
7128−1=127128 - 1 = 127, prime

Once PP is a large enough prime, however, 2P−12^P - 1 can fail to be prime. Call a Mersenne number that is not prime a Mersenne composite.

Given an integer KK, write a program that finds every Mersenne composite with P≤KP \le K and factors it into primes.

Input

The input has a single integer KK. (K<63K < 63)

Output

Print the prime factorization of every Mersenne composite 2P−12^P - 1 with P≤KP \le K, one per line. Each line has this shape.

q1 * q2 * ... * qm = M = ( 2 ^ P ) - 1

Here M=2P−1M = 2^P - 1 and q1≤q2≤⋯≤qmq_1 \le q_2 \le \dots \le q_m are the prime factors of MM in ascending order. A prime that divides MM 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.

Examples1

  1. Example 1

    Input
    31
    
    Expected output
    23 * 89 = 2047 = ( 2 ^ 11 ) - 1
    47 * 178481 = 8388607 = ( 2 ^ 23 ) - 1
    233 * 1103 * 2089 = 536870911 = ( 2 ^ 29 ) - 1