

142857 - merraksh
https://en.wikipedia.org/wiki/142857_%28number%29

======
popctrl
Hey neat, my favorite number is on HN!

Here's an interesting video showing this stuff (And more) in a more user-
friendly way
[https://www.youtube.com/watch?v=WUlaUalgxqI](https://www.youtube.com/watch?v=WUlaUalgxqI)

~~~
rbonvall
It's also my favorite number, but I don't think any of us likes it more than
the guy in the video :) Thanks for sharing.

I learned about 142857 when reading The Man Who Counted as a kid. I remember
getting obsessed with it and discovering more properties (much fewer than the
ones shown on the video), e.g.:

    
    
        142 + 857 = 999
        14 + 28 + 57 = 99

~~~
zyrthofar
You can go even further.

142 + 857 = 999; 9 + 9 + 9 = 27; 2 + 7 = 9

14 + 28 + 57 = 99; 9 + 9 = 18; 1 + 8 = 9

1 + 4 + 2 + 8 + 5 + 7 = 27; 2 + 7 = 9

Also,

1428 + 57 = 1485; 1 + 4 + 8 + 5 = 18; 1 + 8 = 9

14 + 2857 = 2871; 2 + 8 + 7 + 1 = 18; 1 + 8 = 9

1 + 42857 = 42858; 4 + 2 + 8 + 5 + 8 = 27; 2 + 7 = 9

1 + 42857 = 42858; 42 + 858 = 900; 9 + 0 + 0 = 9

This is kinda creepy. I wasn't really expecting the "also" additions to work.

~~~
schoen
If you have any multiple of 9 and repeatedly add the digits, you get back to
9:

[https://en.wikipedia.org/wiki/Digital_root](https://en.wikipedia.org/wiki/Digital_root)

Conversely, if you have any number whose digits added together sum to 9 (or a
multiple of 9), the original number is a multiple of 9.

So, _all_ of your original sum numbers (999, 99, 27, 1485, 2871, and 42858)
are themselves multiples of 9, which will be the case for any number obtained
by adding a set of numbers which together contain all and only the digits
142857. That means a lot of other "also" additions will work out too! You can
even change the order, like 578 + 214 = 792 (a multiple of 9, and hence the
digital root will end up being 9). Any order and any choice of how to break
the numbers will work, because of the digital root property (and, importantly,
the rule that "The digital root of a + b is congruent with the sum of the
digital root of a and the digital root of b modulo 9").

~~~
kazinator
> _multiples of 9, which will be the case for any number obtained by adding a
> set of numbers which together contain all and only the digits 142857_

So that, then, is the fascinating root observation: that any series of decimal
number made from these digits is a multiple of nine.

What this means is that we can choose six random powers of 10 between 10 __0
and 10 __5 and make vector out of them, for instance <1, 100, 10, 10, 100000,
1000>. Then we do a dot-product between this and the vector <1, 4, 2, 8, 5,
7>. The result will be a multiple of 9.

If we choose the vector as <1, 1, 1, 1, 1, 1> we get the straight sum of the
digits. If we choose <100000, 10000, 1000, 100, 10, 1> we get 142857, and so
on.

Here is why it works:

    
    
       10**<whatever> x == x (mod 9).
    

That is to say, any integer x is congruent, modulo 9, to a power of 10 times
that integer.

For instance 4 mod 9 == 4. 40 mod 9 == 4. 400 mod 9 == 4.

And the reason for that is that 10 is 9 + 1; i.e. 10 is congruent to 1 modulo
9. So we are really multiplying by 1 under the congruence.

So the choices of powers of ten in the coefficient vector do not matter.

It works in other bases. For instance if any integer x is multiplied by a
power of 6, that is congruent to x, modulo 5:

    
    
      $ clisp -q
      [1]> (mod (* 2) 5)
      2
      [2]> (mod (* 6 2) 5)
      2
      [3]> (mod (* 6 6 2) 5)
      2
      [4]> (mod (* 6 6 6 2) 5)
      2
    

Elementary number theory, my dear Watson.

Okay, I now wrapped my hackerly head around this enough that I can garbage
collect it away as fairly uninteresting.

:)

But, one more thing: what is special about 1, 4, 2, 8, 5, 7 in connection to
9? Why, they are relatively prime to 9. The remaining three positive residues
in the mod 9 congruence are not: 0, 3 and 6.

See here:
[https://en.wikipedia.org/wiki/Euler%27s_totient_function](https://en.wikipedia.org/wiki/Euler%27s_totient_function)

Euler's totient function phi counts the number of such integers. phi(9) == 6
(there are six of these numbers for 9). The above page even uses this very
example.

1, 4, 2, 8, 5, 7 comprise the _multiplicative group_ of integers modulo 9.

[https://en.wikipedia.org/wiki/Multiplicative_group_of_intege...](https://en.wikipedia.org/wiki/Multiplicative_group_of_integers_modulo_n)

~~~
schoen
The "other bases" issue, which you come to right at the end, fascinated me in
middle school: for the reasons you describe, digital root tests for
divisibility by a digit d work in any base b if d divides (b-1). For example,
in hexadecimal there is a digital root test for divisibility by 1 (trivially),
3, 5, or 15 in hexadecimal.

For instance, D+E+A+D+B+E+E+F=104₁₀ which is not divisible by 5, but that
indicates that (DEADBEEF+1) will be divisible by 5, which is correct.

We're also used to the "final digit test" for divisibility in base 10, which
works for 1 (trivially), 2, 5, and 10; and indeed it works for a digit d in a
base b if d divides b. Ternary has a digital-root test to determine whether a
number is _even_ (as in all odd bases, you can't use the final digit alone to
answer that question). For example, 1202112₃ is odd because 1+2+0+2+1+1+2 is
odd.

(Edit: deleted a spurious claim about hexadecimal divisibility tests.)

------
tomkwok
There is a detailed explanation on Quora [0] that I stumbled upon some time
ago.

[0]: [http://www.quora.com/Why-does-the-number-142857-have-such-
in...](http://www.quora.com/Why-does-the-number-142857-have-such-interesting-
properties)

------
dstyrb
Hahaha, I like how they include: "If it is multiplied by 2, 3, 4, 5, or 6, the
answer will be ... 2/7, 3/7, 4/7, 5/7, or 6/7 respectively."

Was it surprising to multiply 1/7 by two and get 2/7? Has science gone too
far?

~~~
misframer
The point of that sentence, which you have excluded, was about the cyclical
permutations.

~~~
dstyrb
I said the clause was an unnecessary inclusion, the ellipses are there
specifically to highlight that. The rest of the article is about the cyclicity
of the digit.

~~~
mikeash
Your ellipses completely change the meaning. The clause may be unnecessary (as
is the entire article) but the bit you complain about is useful if you don't
chop things out first.

~~~
dstyrb
Well, not sure it was a complaint, I was just lightheartedly commenting that
it was a bit redundant, but ok, umbrage seems a reasonable response.

And yeah, that's pretty much the point of eliding bits of text, to put things
together that weren't together before; I'm almost positive that's why we
invented that specific punctuation mark.

It's like saying: "The 35th president of the United States, JFK, who was
widely known for the space race and the bay of pigs, was elected after the 34
presidents before him."

And my comment is like: "The 35th president of the United States ... was
elected after the 34 presidents before him."

~~~
mikeash
My point is that ellipses are for when you're excising something that is
redundant to your purposes and whose omission doesn't change the overall
meaning.

Your example with JFK is fine. Here's a counterexample where it doesn't work:
"JFK had an affair with Marilyn Monroe, who was a famous Hollywood actress."
-> "JFK... was a famous Hollywood actress."

I maintain that your shortened quote is more like this. The article says that
142857, when multiplied, produces numbers which _correspond to_ the digits of
2/7, 3/7, 4/7, etc.

Your version of the quote omits the words "correspond to," changing it from an
observation about how an integer matches the decimal expansion of a fraction
to an observation about how multiplying a number gets you a multiple of that
number.

------
baseballmerpeak
1/7 = 0.14+0.0028+0.000056+0.00000112+0.0000000224+...

14=2(7) 28=4(7) 56=8(7) 112=16(7) 224=32(7)

------
caligastia
There is a priceless video at
[https://www.youtube.com/watch?v=UKPwZqUUrQo](https://www.youtube.com/watch?v=UKPwZqUUrQo)
of the Gurdjieff movements, the dance at 3:24 is an expression of a
computational process.

