Iterated digits squaring: Difference between revisions

m
m (fix markup)
Line 1,685:
But note that while the task description claims "you always end with either 1 or 89", that claim is somewhat arbitrary.
:But only somewhat the loop is 89 ? 145 ? 42 ? 20 ? 4 ? 16 ? 37 ? 58 ? 89, so it only ends with 1 or one of the numbers in this loop. 42 is of course far more significant and the one I would choose!!--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 10:12, 16 September 2014 (UTC)
:: You should move this comment (and my reply here) to the talk page. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 03:01, 26 September 2022 (UTC)
 
<syntaxhighlight lang="j"> sumdigsq^:(i.16) 15
15 26 40 16 37 58 89 145 42 20 4 16 37 58 89 145</syntaxhighlight>
 
Here, after the initial three values, the final digit repeats with a period of 8 (so it does not end).
 
<syntaxhighlight lang=J> 10 8$sumdigsq^:(i.80) 15
15 26 40 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145
42 20 4 16 37 58 89 145</syntaxhighlight>
 
You could just as easily claim that you always end with either 1 or 4. So here's a routine which repeats the sum-square process until the sequence converges, or until it reaches the value 4:
6,962

edits