News for hackers. Stuff that matters.
Re:Squared Digit Sum by jwilk on Saturday March 24, 2018 @12:28PM (#16667402)
Sketch of a proof:

Let f(n) be the sum the squares of digits of n.

For k-digit number: f(n) ≤ 81k.

That is: f(n) ≤ 81 × (1 + ⌊log₁₀n⌋)

It's pretty clear that if n≥1000, f(n) < n. So the n, f(n), f(f(n)), ... sequence will eventually reach a number below 1000.

Mechanical proof for numbers below 1000 is in the article.

Re:Squared Digit Sum by Someone on Saturday March 24, 2018 @02:32PM (#16668053)
Because f(n) = log(n) eventually grows arbitrarily slower then f(n) = n, no matter what the base of that logarithm is, you can generalize that to arbitrary number base b > 2 and arbitrary powers p > 2, and show that any starting number will eventually reach a cycle.

Now, one can ask question such as:

- for which (number base, power) pairs is that cycle unique?

- for which (number base, power) pairs is that cycle shortest? (For example, 153 = 1³ + 5³ + 3³, so if (base 10, power 3) has only one such cycle, it has length 1. Similarly, 4150 = 4^⁵ + 1^⁵ + 5^⁵ + 0^⁵ could be the unique cycle of length 1 for base 10, power 5.

- what does the function f(base, power) look like?

Re:Squared Digit Sum by resource0x on Saturday March 24, 2018 @01:07PM (#16667582)
> if n≥1000, f(n) < n

And this is what makes the setup not very interesting. Compare with 3x+1 problem, where the sequence can grow, but eventually comes down (there's a simple probabilistic argument for that, but no formal proof).

Re:Squared Digit Sum by mannykannot on Saturday March 24, 2018 @12:56PM (#16667528)
Good point. The first response to the original article mentions 162 (2 * 81) as a value that the process will always eventually fall below, presumably arrived at by this argument.
Re:Squared Digit Sum by nayuki on Saturday March 24, 2018 @11:58AM (#16667243)
This topic happens to be Project Euler problem #92. https://projecteuler.net/problem=92
Re:Squared Digit Sum by arconis987 on Saturday March 24, 2018 @12:14PM (#16667337)
A similar problem was in Google Code Jam 2009 :)

https://code.google.com/codejam/contest/188266/dashboard

Re:Squared Digit Sum by jwilk on Saturday March 24, 2018 @12:17PM (#16667359)
Archived copy, which works with JS disabled:

https://archive.is/2pPTN

Re:Squared Digit Sum by nayuki on Saturday March 24, 2018 @02:52PM (#16668170)
Error 503 Service Unavailable

Service Unavailable

Guru Meditation:

XID: 363037244

Varnish cache server

Re:Squared Digit Sum by labster on Saturday March 24, 2018 @11:44PM (#16670601)
You can compete against other code golfers for the shortest Happy Numbers solution on code-golf.io https://code-golf.io/happy-numbers
Re:Squared Digit Sum by Goopplesoft on Saturday March 24, 2018 @04:56PM (#16668882)
Re:Squared Digit Sum by gweinberg on Saturday March 24, 2018 @10:01PM (#16670229)
Happy numbers led me to Fortunate numbers, which are Fortunate not because they are well off but because the guy studying them was named Fortune. https://en.wikipedia.org/wiki/Fortunate_number Fortune conjectured that all Fortunate numbers are prime. I know jack about number theory but isn't that obvious from the density of primes? If there were a composite Fortunate number Fn it couldn't have any factors less than the nth prime number, which means it would have to be greater than the nth prime number squared.
Re:Squared Digit Sum by cperciva on Sunday March 25, 2018 @12:59AM (#16670843)
Not at all obvious. It is a very open question whether prime gaps are bounded by ~(log N)^2... AFAIK, even assuming the GRH, the best upper bound is roughly N^(1/2).
Re:Squared Digit Sum by jwilk on Sunday March 25, 2018 @07:21AM (#16671698)
Re:Squared Digit Sum by cperciva on Sunday March 25, 2018 @08:50PM (#16675686)
Yeah, that's the conjecture I was thinking of.
Re:Squared Digit Sum by taeric on Saturday March 24, 2018 @02:10PM (#16667930)
Love the plug for emacs org mode. There are few things I evangelize. Sadly, none of my efforts have gotten anyone using it, to my knowledge. :/
Re:Squared Digit Sum by eat_veggies on Saturday March 24, 2018 @02:22PM (#16667996)
I've heard a lot of people talk about how it's a real game changer and that they can't live without it, but I'm not really clear on the specifics as to why. Are there any "killer features" of org mode that I should know about? What exactly does it replace or augment in your workflow? You might be about to get yourself your first conversion to this tool!
Re:Squared Digit Sum by taeric on Saturday March 24, 2018 @04:08PM (#16668604)
The article that was posted a few days about about literate dev ops covered all of the amazing features, to me.

The part that is hard to really convey is just the fun of it. Being able to run a log dive to grab some data using standard grep/whatever, then to immediately pull it into either R or Python or just Gnuplot to get a visual is quite a nice trick. Top it off with a quick export to pdf/html/markdown to send to someone to confirm it. (Typically a stakeholder.)

Add to this emacs TRAMP capabilities and I just need whatever tool I want on a machine I can ssh to. Don't have a good install of python locally for some reason, just set the :dir attribute of the block to my machine (or docker container. Or a series of jumps through combinations!) that has it, and I'm good.

It does have some growing pains sometimes. I found that the SQL plugin didn't do the passwords as I wanted it to. But, that was a simple breakpoint and hot code fix away. (I, regretably, did not prepare a patch to send upstream...)

Re:Squared Digit Sum by eat_veggies on Saturday March 24, 2018 @05:04PM (#16668932)
That sounds dope. I'll give it a spin! It'll be my first time using emacs--do you recommend plain emacs, or something like spacemacs?
Re:Squared Digit Sum by CJefferson on Saturday March 24, 2018 @08:52PM (#16669972)
I recently tried slacemacs, and based in my experience is use plain emacs.

The problem with spacemacs as a beginner is it isn't quite emacs, and it isn't quite vim, and as a beginner you don't know how to translate vim and Emacs guides to spacemacs.

Re:Squared Digit Sum by taeric on Saturday March 24, 2018 @05:39PM (#16669117)
Been so long since I made the switch, hard to say. I actually preferred being in an all new situation. And u used to constantly switch keyboard types and mouse hand.

Main advice I have, that I don't think I really followed, make time. Literally pick some time to do something you were going to do anyway, but that you aren't in a rush to do. Preferably not on any critical path. It will be slower.

Re:Squared Digit Sum by andreareina on Sunday March 25, 2018 @06:21AM (#16671564)
It's not so much that there's a single killer feature, but that it's able to pull from everything that emacs already does well, and interoperate between them. A common use-case for me is using one language to process some data then passing the result to another tool (e.g. gnuplot, graphviz) visualize the results.
Re:Squared Digit Sum by early on Saturday March 24, 2018 @03:08PM (#16668272)
I am happy to see that 42 is part of the answer
Re:Squared Digit Sum by theophrastus on Saturday March 24, 2018 @12:45PM (#16667484)
These are certainly cool. Yet everytime I've stumbled over them, I find that "Integer Sequences"[1] 'already did it'. And that's true for this case too[2].

[1] https://oeis.org/

[2] https://oeis.org/A000216

Re:Squared Digit Sum by jwilk on Saturday March 24, 2018 @01:12PM (#16667611)
OEIS links to PDF with Arthur Porges's proof:

https://oeis.org/A003621/a003621.pdf