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!
Project Euler 38: Solving with Pen and Paper Like Itβs 1899 ποΈ