Project Euler Lab - Problem 462

#462 - Permutation of 3-smooth Numbers

● AdvancedOfficial difficulty: 59%DivisibilityTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

A \(3\)-smooth number is an integer which has no prime factor larger than \(3\). For an integer \(N\), we define \(S(N)\) as the set of \(3\)-smooth numbers less than or equal to \(N\). For example, \(S(20) = \{ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18 \}\).

We define \(F(N)\) as the number of permutations of \(S(N)\) in which each element comes after all of its proper divisors.

This is one of the possible permutations for \(N = 20\).
- \(1, 2, 4, 3, 9, 8, 16, 6, 18, 12.\)
This is not a valid permutation because \(12\) comes before its divisor \(6\).
- \(1, 2, 4, 3, 9, 8, \boldsymbol{12}, 16, \boldsymbol 6, 18\).

We can verify that \(F(6) = 5\), \(F(8) = 9\), \(F(20) = 450\) and \(F(1000) \approx 8.8521816557\mathrm e21\).
Find \(F(10^{18})\). Give as your answer its scientific notation rounded to ten digits after the decimal point.
When giving your answer, use a lowercase e to separate mantissa and exponent. E.g. if the answer is \(112\,233\,445\,566\,778\,899\) then the answer format would be 1.1223344557e17.

This problem is taken from Project Euler, Problem 462.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=462. Published Saturday, 8th March 2014, 07:00 pm. Solved by 405 members at time of mirroring.

Why this is useful

Numerical Computing. Precision, conditioning, and numerical iteration transfer directly to pricing engines and model calibration (Phases 5, 13, 15).

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.