The mysterious mathematical billboard that appeared in Silicon Valley
This project solves old mathematical puzzle that appeared on a billboard in Silicon Valley. The billboard showed a URL in the format:
{first 10-digit prime found in consecutive digits of e}.com
The answer is 7427466391.com
. Our program finds this number in approximately 0.002 seconds!
The solution combines several mathematical and computational techniques:
-
Generating e's Digits
- Uses scaled integer arithmetic for perfect precision
- Implements the series: e = 2 + 1/1! + 1/2! + ...
- Adds extra precision digits for accuracy
-
Prime Testing
def is_prime(number): if number < 2: return False if number == 2: return True if number % 2 == 0: return False for i in range(3, int(number ** 0.5) + 1, 2): if number % i == 0: return False return True
-
Sliding Window Search
- Efficiently searches through consecutive digits
- Converts digit sequences to numbers
- Tests each number for primality
First 10-digit prime in e: 7427466391
Time taken: 0.0023488998413085938 seconds
- Pure Python implementation
- No external dependencies
- Fairly fast execution
- Well-covered test suite
- Well-documented code
- Mathematical elegance
from euler_prime import find_first_prime_in_e
# Find first 10-digit prime in e
result = find_first_prime_in_e(10)
print(f"First 10-digit prime in e: {result}")
Run the tests using pytest:
python -m pytest tests/
.
├── README.md
├── euler_prime.py # Main implementation
├── tests/
│ └── test_euler.py # Test cases
├── requirements.txt # Project dependencies
└── LICENSE # MIT License
Euler's number (e) is a mathematical constant approximately equal to 2.71828... It can be represented as an infinite series:
e = 2 + 1/1! + 1/2! + 1/3! + 1/4! + ...
Our implementation uses this series along with scaled integer arithmetic to generate precise digits of e.
The solution employs several optimizations:
- Early termination in primality testing
- Efficient digit extraction
- Smart precision handling
- Sliding window optimization
This project is licensed under the MIT License - see the LICENSE file for details.
[Danil Zanozin][https://github.com/danilmezor]
- Google for creating this puzzle
- The mathematical beauty of Euler's number
- The open-source community
Made with ❤️ and Python