<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Project_Euler%2F92</id>
	<title>Project Euler/92 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Project_Euler%2F92"/>
	<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/92&amp;action=history"/>
	<updated>2026-06-25T05:33:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://charlesreid1.com/w/index.php?title=Project_Euler/92&amp;diff=30819&amp;oldid=prev</id>
		<title>Admin: replace source tag with syntaxhighlight tag (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/92&amp;diff=30819&amp;oldid=prev"/>
		<updated>2026-06-24T17:20:54Z</updated>

		<summary type="html">&lt;p&gt;replace source tag with syntaxhighlight tag (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:20, 24 June 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is problem 92 on Project Euler: https://projecteuler.net/problem=92&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is problem 92 on Project Euler: https://projecteuler.net/problem=92&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l42&quot;&gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: https://git.charlesreid1.com/cs/euler/src/branch/main/java/Problem092.java&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: https://git.charlesreid1.com/cs/euler/src/branch/main/java/Problem092.java&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source &lt;/del&gt;lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight &lt;/ins&gt;lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;public class Problem092 {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;public class Problem092 {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l76&quot;&gt;Line 76:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 77:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Flags=&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Flags=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff::1.12:old-30803:rev-30819 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://charlesreid1.com/w/index.php?title=Project_Euler/92&amp;diff=30803&amp;oldid=prev</id>
		<title>Admin: Create Project Euler/92 page with problem statement, solution approach, and Java solution (via create-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/92&amp;diff=30803&amp;oldid=prev"/>
		<updated>2026-06-24T11:29:55Z</updated>

		<summary type="html">&lt;p&gt;Create Project Euler/92 page with problem statement, solution approach, and Java solution (via create-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is problem 92 on Project Euler: https://projecteuler.net/problem=92&lt;br /&gt;
&lt;br /&gt;
=Overview of the Problem=&lt;br /&gt;
&lt;br /&gt;
==Question==&lt;br /&gt;
&lt;br /&gt;
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example,&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;44 \to 32 \to 13 \to 10 \to \mathbf{1} \to \mathbf{1}&amp;lt;/math&amp;gt;&lt;br /&gt;
:&amp;lt;math&amp;gt;85 \to \mathbf{89} \to 145 \to 42 \to 20 \to 4 \to 16 \to 37 \to 58 \to \mathbf{89}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore any chain that arrives at &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt; will become stuck in an endless loop. What is most amazing is that &amp;#039;&amp;#039;&amp;#039;every&amp;#039;&amp;#039;&amp;#039; starting number will eventually arrive at &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
How many starting numbers below ten million will arrive at &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt;?&lt;br /&gt;
&lt;br /&gt;
=Solution Approach=&lt;br /&gt;
&lt;br /&gt;
The key observation for this problem is that the sum of squared digits for any number below ten million is at most &amp;lt;math&amp;gt;7 \times 9^2 = 567&amp;lt;/math&amp;gt;. This means every chain quickly collapses into the small state space &amp;lt;math&amp;gt;1 \dots 567&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can break the problem into two phases:&lt;br /&gt;
&lt;br /&gt;
==Phase 1: Precompute chain destinations for 1 through 567==&lt;br /&gt;
&lt;br /&gt;
For each integer &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;567&amp;lt;/math&amp;gt;, follow its digit-square-sum chain until it reaches either &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt;. Cache the result (a boolean: &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the chain arrives at &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt;) in an array. Walking the chain is cheap because these numbers are small, and once a chain hits a previously cached value, we can short-circuit.&lt;br /&gt;
&lt;br /&gt;
==Phase 2: Count arrivals at 89 for all numbers below ten million==&lt;br /&gt;
&lt;br /&gt;
For each starting number &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;9,999,999&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
# Compute &amp;lt;math&amp;gt;s = \text{sumOfSquaredDigits}(n)&amp;lt;/math&amp;gt;. This value is in the range &amp;lt;math&amp;gt;0 \dots 567&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Look up the cached result for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If the cached result is &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; (i.e., the chain ultimately reaches &amp;lt;math&amp;gt;89&amp;lt;/math&amp;gt;), increment the count.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sumOfSquaredDigits&amp;lt;/code&amp;gt; helper repeatedly extracts the last digit of &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, squares it, adds it to a running sum, and divides &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This approach runs in &amp;lt;math&amp;gt;O(N \cdot d)&amp;lt;/math&amp;gt; time where &amp;lt;math&amp;gt;N = 10^7&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;d \approx 7&amp;lt;/math&amp;gt; digits, making it fast enough for a single-threaded Java implementation.&lt;br /&gt;
&lt;br /&gt;
=Java Solution=&lt;br /&gt;
&lt;br /&gt;
The full implementation is available in the Euler Git repository:&lt;br /&gt;
&lt;br /&gt;
: https://git.charlesreid1.com/cs/euler/src/branch/main/java/Problem092.java&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Problem092 {&lt;br /&gt;
&lt;br /&gt;
    private static int sumOfSquaredDigits(int n) {&lt;br /&gt;
        int sum = 0;&lt;br /&gt;
        while (n &amp;gt; 0) {&lt;br /&gt;
            int d = n % 10;&lt;br /&gt;
            sum += d * d;&lt;br /&gt;
            n /= 10;&lt;br /&gt;
        }&lt;br /&gt;
        return sum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        boolean[] cache = new boolean[568];&lt;br /&gt;
&lt;br /&gt;
        for (int i = 1; i &amp;lt;= 567; i++) {&lt;br /&gt;
            int n = i;&lt;br /&gt;
            while (n != 1 &amp;amp;&amp;amp; n != 89) {&lt;br /&gt;
                n = sumOfSquaredDigits(n);&lt;br /&gt;
            }&lt;br /&gt;
            cache[i] = (n == 89);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        int count = 0;&lt;br /&gt;
        for (int i = 1; i &amp;lt; 10_000_000; i++) {&lt;br /&gt;
            if (cache[sumOfSquaredDigits(i)]) {&lt;br /&gt;
                count++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        System.out.println(count);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Flags=&lt;br /&gt;
&lt;br /&gt;
{{ProjectEulerFlag}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Project Euler]]&lt;br /&gt;
[[Category:Java]]&lt;br /&gt;
[[Category:Number Theory]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>