← Writing

Project Euler 38: Solving with Pen and Paper Like It’s 1899 πŸ–ŠοΈ

In the age of compilers and cloud computing, it’s easy to forget how powerful logic and a pencil can be. Project Euler Problem 38 β€” finding the largest 1 to 9 pandigital number formed as a concatenated product β€” is typically solved with code. But what if we couldn’t code it? Could we solve it by Hand?

Surprisingly, yes. Let’s dive into how to tackle this delightful puzzle the old-school way.


🧩 The Problem Statement

We want to find the largest 9-digit pandigital number (i.e., one that uses digits 1 to 9 exactly once) that can be formed as:

a concatenated = integer Γ— 1 || integer Γ— 2 || ... || integer Γ— n

Where n > 1, and || means “concatenate the results.”


🧠 Step-by-Step Reasoning

Here’s how to break this down with logic and no laptop:

1. Understand the Constraints

  • We need exactly four digits.
  • No repeats.
  • No zeroes.
  • Each will be used only once.

2. Start from the Top

Because we want the largest number, it probably starts with 9. So let’s try 4-digit numbers beginning with 9. Why four digits?

3. Think in Terms of Digit Count

Let’s assume the base number is x digits long, and we multiply it by (1, 2, ..., n) until we hit exactly nine digits total.

  • A 1-digit number, like 9, β†’ 9 Γ— (1, 2, 3, 4, 5) might work.
  • A 2-digit number like 91 β†’ digits add up fast, but might still work.
  • A 4-digit number like 9327 β†’
    • Γ—1 = 4 digits
    • Γ—2 = 5 digits
    • 4 + 5 = 9 digits βœ…

So let’s focus on 4-digit numbers and multiply them by 1 and 2.

🧠 Digits Available: {1, 2, 3, 4, 5, 6, 7, 8, 9} Total = 9 digits We’re fixing the first digit as 9, so we’re left with:

8 digits to choose from for the remaining 3 positions

βœ… Counting First digit: 9 (fixed)

Second digit: choose 1 of 8 (excluding 9)

Third digit: choose 1 of remaining 7

Fourth digit: choose 1 of remaining 6

Total=1Γ—8Γ—7Γ—6= 336

βœ… Final Answer: There are 336 valid 4-digit numbers that:

Start with 9

Use digits 1–9 (no zero)

Have no repeated digits


✍️ Example Walkthrough (By Hand)

Let’s try a candidate: 9327

  • 9327 Γ— 1 = 9327
  • 9327 Γ— 2 = 18654
  • Concatenate: 932718654

Is this pandigital?

Check manually: βœ”οΈ 1 βœ”οΈ 2 βœ”οΈ 3 βœ”οΈ 4 βœ”οΈ 5 βœ”οΈ 6 βœ”οΈ 7 βœ”οΈ 8 βœ”οΈ 9 βœ”οΈ No zeroes βœ”οΈ No repeats

Bingo!


πŸ—ƒοΈ Systematic Exploration Table

Create a handwritten table to test other candidates:

BaseΓ—1Γ—2ConcatPandigital?
9182918218364918218364❌ Repeats
9234923418468923418468❌ Repeats
9327932718654932718654βœ… Yes
9876987619752987619752❌ Repeats

Take your time. Cross-check digits. Circle good candidates.


🏁 The Final Answer

After some searching and manual checking, you’ll find:

932718654 is the largest 1–9 pandigital number formed as the concatenated product of (9327 Γ— 1 || 9327 Γ— 2).

All without a single line of code.


πŸ’‘ Why This Matters

Solving puzzles like this by Hand:

  • Sharpens logic skills.
  • Builds appreciation for digit-based reasoning.
  • Brings you closer to the problem than a program ever could.

Sure, a few lines of Python can brute-force the answer. But the satisfaction of cracking it with only a pencil and patience? Priceless.


🧠 Challenge for You

Try solving Euler Problem 52 or 41 by Hand. They’re also digit-based and rewarding.

Or better yet β€” give this one a go without reading this solution and see where your logic takes you!

Prev: The Fascinating World of Pandigital Multiples

Next: Programmatically Finding Pandigital Multiples

More