Project Euler Lab - Problem 636

#636 - Restricted Factorisations

● ResearchOfficial difficulty: 83%CountingTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

Consider writing a natural number as product of powers of natural numbers with given exponents, additionally requiring different base numbers for each power.

For example, \(256\) can be written as a product of a square and a fourth power in three ways such that the base numbers are different.
That is, \(256=1^2\times 4^4=4^2\times 2^4=16^2\times 1^4\)

Though \(4^2\) and \(2^4\) are both equal, we are concerned only about the base numbers in this problem. Note that permutations are not considered distinct, for example \(16^2\times 1^4\) and \(1^4 \times 16^2\) are considered to be the same.

Similarly, \(10!\) can be written as a product of one natural number, two squares and three cubes in two ways (\(10!=42\times5^2\times4^2\times3^3\times2^3\times1^3=21\times5^2\times2^2\times4^3\times3^3\times1^3\)) whereas \(20!\) can be given the same representation in \(41680\) ways.

Let \(F(n)\) denote the number of ways in which \(n\) can be written as a product of one natural number, two squares, three cubes and four fourth powers.

You are given that \(F(25!)=4933\), \(F(100!) \bmod 1\,000\,000\,007=693\,952\,493\),
and \(F(1\,000!) \bmod 1\,000\,000\,007=6\,364\,496\).

Find \(F(1\,000\,000!) \bmod 1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 636.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=636. Published Saturday, 8th September 2018, 10:00 pm. Solved by 248 members at time of mirroring.

Why this is useful

Mathematical Foundation. Exact counting underlies discrete pricing lattices, scenario enumeration, and combinatorial probability (Phase 7).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.