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 = 93279327 × 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 | ×2 | Concat | Pandigital? |
|---|---|---|---|---|
| 9182 | 9182 | 18364 | 918218364 | ❌ Repeats |
| 9234 | 9234 | 18468 | 923418468 | ❌ Repeats |
| 9327 | 9327 | 18654 | 932718654 | ✅ Yes |
| 9876 | 9876 | 19752 | 987619752 | ❌ 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!

Previous

Next