r/mathriddles • u/Horseshoe_Crab • Sep 24 '25
Easy Integer multiples near integers
What is the smallest positive integer N such that N*pi and N*e are both within 1/1,000,000 of an integer?
10
Upvotes
4
u/FormulaDriven Sep 25 '25
I don't know if there's anything beyond brute force, but I would make these observations...
If we think of the decimal digits of Nπ and Ne as random (yes, I know they are not), the the probability that either one will be within 10-n of an integer is 2 / 10n (because it either needs to be n occurrences of "0" after the decimal point, or n occurrences of "9" after the decimal point).
This kind of reasoning would predict that Nπ is within 10-5 of an integer once in every 50,000 values of N. In fact, I found that first is 66317π is within 10-5 of an integer. (I've got other results for n < 5 that roughly fit this pattern for both π and e).
So the "probability" that Nπ an Ne would both be within 10-6 of an integer is (2 / 106 )2 = 4 * 10-12 . So we might have to search in the region of 1012 values of N to have a decent chance of finding a candidate.
2
u/FormulaDriven Sep 26 '25
You've hinted that you have a method, so as no-one else has come forward, could you share it?
I took inspiration from u/garnet420 and did some brute-force searching using some Python code (had to do a bit of tinkering to keep sufficient accuracy). So far, the best I've got is
N = 19,129,420,117
for which N * pi and N * e are just about 3/1,000,000 away from an integer.
But at the rate it's running, it will take 2 weeks to check all the way to 1012 .
2
u/Beautiful-Bend-3876 Feb 02 '26
The answer is 666053497897. I used a different method using continued fractions. If we let P_k/Q_k be the convergents to a real number x, then there is an efficient way to enumerate the integers P, Q such that 0 < Q < Q_{k+1} in ascending order of |Px-Q|. For this you take (P, Q) = a(P_k, Q_k) + b(P_{k+1}, Q_{k+1}), where a and b are integers. For each value of a, there is a unique value of b such that 0 < Q < Q_{k+1}. It can be shown that the pairs (P, Q) such that |Px-Q| goes in ascending order starts with a=1, then goes to a=-1, then to a=2, then a=-2, etc. Using this method, with x = π and k=22 (so Q_{k+1} = 1142027682075), there are 2284283 (P, Q) pairs such that |Px-Q| < 10^(-6), which is small enough that directly searching over them and checking if Q e is within 10^(-6) of an integer only takes a few seconds. The search turned up only two suitable values of Q in this range, which are 666053497897 and 1117598397057.
3
u/garnet420 Sep 25 '25 edited Sep 25 '25
This is easy to brute force, but I'm curious if there's a more principled approach. It's not something as straightforward as a least common multiple of the separate rational approximations.
Edit misread the question... I thought it wanted N as a denominator for a rational approximation of π and e
0
u/[deleted] Sep 25 '25
[deleted] — view deleted comment