TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fun with math: Dividing one by 998001 yields a surprising result

754 pointsby kenverover 13 years ago

30 comments

psykoticover 13 years ago
There's some sleight of hand here. Not all the digits are exactly right. Look how it skips from 997 to 999:<p><a href="http://www.futilitycloset.com/2012/01/08/math-notes-76/" rel="nofollow">http://www.futilitycloset.com/2012/01/08/math-notes-76/</a><p>Here's the math. Suppose you want a unit fraction 1/n with decimals that cycle through the 4-digit sequence abcd. Multiply by 10^4 to shift abcd into integer position, leaving repeating copies after the decimal point:<p><pre><code> 10^4/n = abcd + 1/n </code></pre> Solving for n gives n = (10^4 - 1) / abcd.<p>More generally, if you want to get a cycle equal to the d digits of an integer k, you want n = (10^d - 1) / k.<p>However, this only gives a true unit fraction when k divides 10^d - 1, so that n is an integer. Otherwise you are forced to truncate n and getting an approximate version of the cycle.<p>That's exactly what happened here: 10^d - 1 is not divisible by the integer 001002...998999.<p>Here's a small Python program that will generate the unit fraction given the number of digits to cycle through:<p><pre><code> import sys n = int(sys.argv[1]) s = ''.join(("%0" + str(n) + "d") % (i,) for i in range(10**n)) print "1/%d" % ((10**len(s) - 1) / int(s),) </code></pre> Usage:<p><pre><code> $ python magic.py 3 1/998001 $ python magic.py 4 1/99980001 </code></pre> This has just the right flavor for a Project Euler problem.
评论 #3515013 未加载
评论 #3515115 未加载
评论 #3521752 未加载
评论 #3517222 未加载
fryguyover 13 years ago
A simple way to figure out how this works is to figure out another way to write it out. For the simpler case (1/9801) = 0.00010203...<p><pre><code> 0.00 + 0.0001 + 0.000002 + 0.00000003 ... -------------- </code></pre> Each row is equal to x, but shifted over 2x digits. This is the same as dividing by 10^x. This simplifies to the formula:<p><pre><code> sum k=0 to infinity: k/(10^k) </code></pre> This is fairly easily calculable, and results in 1/9801. Try it yourself on wolfram alpha: <a href="http://www.wolframalpha.com/input/?i=%28sum_%28k%3D1%29%5Einfinity%28%28k-1%29%2F%28100%5Ek%29%29" rel="nofollow">http://www.wolframalpha.com/input/?i=%28sum_%28k%3D1%29%5Ein...</a>
tylerneylonover 13 years ago
The general any-number-base-b rule here (as others have noticed in base 10^k) is that<p>1/(b-1)^2 = 0.0123456... (where '1', '2'.. are base b digits).<p>The original post is this fact in base 1000.<p>Proof for any base: 1/(b-1) = 1/b + 1/b^2 + 1/b^3 + .. = 0.11111.. (base b).<p>So 1/(b-1)^2 = 0.11111.. * (1/b + 1/b^2 + 1/b^3 + ...) = 0.012345... QED.<p>Richard Feynman beat us all to the punch here by noticing that 1/243 = 0.004115226337..., a fact which he wrote in a letter from a secret lab to someone in the outside world, and which put him under suspicion of sending secret messages! That gem of a fraction turns out to be a result of the above stuff as 1/243 = 111 * (1/999^2) + 4/999.<p>Here's a slightly more detailed explanation:<p><a href="http://tylerneylon.com/b/archives/51" rel="nofollow">http://tylerneylon.com/b/archives/51</a>
saraid216over 13 years ago
I just want to repeat bdg's appreciation for the people who are explaining the actual theory, which is the interesting part. Funky results from arbitrary arithmetic is just a step short of numerology and while it's nifty in a stage magic kind of way, it's a little sad overall when you have no idea <i>why</i> that's the way it is.
评论 #3517290 未加载
archgoonover 13 years ago
This can be seen in python with (I had to dig into the docs for this, so here are the fruits of my labor :) )<p><pre><code> import decimal decimal.getcontext().prec=1000 dec = decimal.Decimal(1)/decimal.Decimal(998001) #now doctor it up to see the numbers strdec = str(dec)[2:] #chop off the '0.' nums = zip(strdec[::3],strdec[1::3],strdec[2::3]) print nums</code></pre>
评论 #3514893 未加载
评论 #3514983 未加载
评论 #3514879 未加载
评论 #3515397 未加载
评论 #3514905 未加载
jerfelixover 13 years ago
... and 1/9999999800000001 = .00000000 00000001 00000002 00000003 00000004 00000005 00000006 ... 99999996 99999997 99999999 ...repeating<p>Basically, the pattern is 1 over some number of 9s, followed by an 8, followed by the same number of 0s, followed by a 1.<p>So, 1/81, 1/9801, 1/998001, 1/99980001, 1/9999800001, etc.
评论 #3515071 未加载
troystriblingover 13 years ago
You can see it at Wolfram Alpha <a href="http://www.wolframalpha.com/input/?i=1%2F998001" rel="nofollow">http://www.wolframalpha.com/input/?i=1%2F998001</a>
kenverover 13 years ago
I was searching for some iOS documentation and found this and it's totally ruined my productivity!<p>Can anyone explain why it repeats in this way, or link to a place that has an explanation?
评论 #3514953 未加载
评论 #3514959 未加载
deltasquaredover 13 years ago
<p><pre><code> ;Here is my version in Common Lisp ;Supply your own flatten function ;or borrow one from let-over-lambda or something ;http://letoverlambda.com/lol.lisp (defun long-div (dividend divisor depth) (cond ((&#62; depth 0) (flatten (list (truncate (/ dividend divisor)) (long-div (* 10 (mod dividend divisor)) divisor (- depth 1))))) (t ())))</code></pre>
m_for_monkeyover 13 years ago
The source with real (readable) text, without annoying animation:<p><a href="http://www.futilitycloset.com/2012/01/08/math-notes-76/" rel="nofollow">http://www.futilitycloset.com/2012/01/08/math-notes-76/</a>
评论 #3514945 未加载
slamduncover 13 years ago
Thanks for posting. I'm trying to keep a collection of these type of things so that when she's ready, it'll be another tool to get/keep my daughter excited about math.
评论 #3514980 未加载
评论 #3518019 未加载
onedognightover 13 years ago
There's no 998 (and it's not a rounding issue)!<p><pre><code> ... 995 996 997 999</code></pre>
评论 #3515025 未加载
评论 #3515030 未加载
评论 #3514973 未加载
评论 #3514977 未加载
bbloombergover 13 years ago
You can find the Catalan numbers buy computing 500,000,000,000 - Sqrt(500,000,000,000*500,000,000,000 - 1)....<p><a href="http://people.csail.mit.edu/devadas/numerics_demo/chord.html" rel="nofollow">http://people.csail.mit.edu/devadas/numerics_demo/chord.html</a><p>For an explanation better than I can provide of what they are and how it works, see 6.006 lecture 11 notes!<p><a href="http://courses.csail.mit.edu/6.006/fall11/lectures/lecture11.pdf" rel="nofollow">http://courses.csail.mit.edu/6.006/fall11/lectures/lecture11...</a>
dimitarover 13 years ago
Some fun that can fit on a poket calculator:<p>12345679 * 9 = 111111111<p>12345679 * 18 = 222222222<p>12345679 * 27 = 333333333<p>12345679 * 36 = 444444444<p>12345679 * 45 = 555555555<p>12345679 * 54 = 666666666<p>12345679 * 63 = 777777777<p>12345679 * 72 = 888888888<p>12345679 * 81 = 999999999<p>12345679 * 999999999 = 12345678987654321
评论 #3517257 未加载
评论 #3517158 未加载
评论 #3517009 未加载
reedcatover 13 years ago
My productivity for today went downhill! :)<p>Love the trick with how this can be done via differentiating the equation:<p>1 + r + r^2 + ... = 1/(1-r)
liljimmytablesover 13 years ago
Slightly off-topic, but it bugs me that the article feels obliged to contain a picture of the number. Firstly, why the hell would you want to display plain text as a picture? Secondly, if I click through to the source, I get a slightly better picture. Did IHC take a photo of the original website with their phone camera and upload it? Mind is boggling. Encouraged by the better quality picture on geekosystem I decided to click through to THEIR source. And there's a plaintext version. Kudos to &#60;a href="<a href="http://www.futilitycloset.com/2012/01/08/math-notes-76/&#60;FutilityCloset&#60;/a&#62" rel="nofollow">http://www.futilitycloset.com/2012/01/08/math-notes-76/&#60;...</a>; for having a modicum of common sense.
sooshover 13 years ago
This reminded me of a fun fact from an old professor's paper: 1/99007599 has a binary expansion of period 48993900.<p><a href="http://www.math.ucsb.edu/~agboola/teaching/2005/winter/old-115A/murty.pdf" rel="nofollow">http://www.math.ucsb.edu/~agboola/teaching/2005/winter/old-1...</a>
jbdevonover 13 years ago
Also, 1/4999 yields the sequence of square numbers.
评论 #3515249 未加载
dbieberover 13 years ago
For all squares, <a href="http://m.wolframalpha.com/input/?i=100010000%2F999700029999&#38;x=0&#38;y=0" rel="nofollow">http://m.wolframalpha.com/input/?i=100010000%2F999700029999&...</a> 100010000/999700029999 Tack on extra 0s and 9s to allocate more digits per square.
jrockwayover 13 years ago
Incidentally, understanding how this works is helpful to programmers. If you know why this happens, you'll know why you can't write:<p><pre><code> double x = 0.1; </code></pre> and get something that works.
评论 #3515258 未加载
foobarbazgarplyover 13 years ago
Is there a number f(n) such that 1/f(n) yields all n-digit numbers, and is there a formula f to generate them?
评论 #3514947 未加载
mauro_otoover 13 years ago
The link is blocked at my workplace. I really don't understand how their filter system works.
评论 #3515039 未加载
评论 #3514897 未加载
评论 #3515379 未加载
mrobatailleover 13 years ago
Set up a recursion: 1000x - .001 (repeating) = x<p>The .001 repeating = 1/999, simplify, voila.
akkartikover 13 years ago
What happens after 999? It wraps around back to 000! This is cool.
评论 #3517697 未加载
ilitiritover 13 years ago
1. Take 1 as a divisor<p>2. Choosing a suitable dividend<p>3. Calculate quotient<p>4. Instant interesting observation!
human_errorover 13 years ago
1/49 is "almost" surprising. 0.0204081632
gsivilover 13 years ago
Try taking the square root of it
Tim-Bossover 13 years ago
That's nothing! 6922251 * 8 on a calculator spells my ex's nickname....
dbboover 13 years ago
Hmm. <a href="http://www.reddit.com/r/math/comments/oiv7s/cool_fraction/" rel="nofollow">http://www.reddit.com/r/math/comments/oiv7s/cool_fraction/</a>
monsterixover 13 years ago
Did you read on Egyptian fractions? <a href="http://en.wikipedia.org/wiki/Egyptian_fraction" rel="nofollow">http://en.wikipedia.org/wiki/Egyptian_fraction</a><p>:)