<?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%2F45</id>
	<title>Project Euler/45 - 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%2F45"/>
	<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/45&amp;action=history"/>
	<updated>2026-06-18T23:12:43Z</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/45&amp;diff=30594&amp;oldid=prev</id>
		<title>Admin: Create Project Euler/45 page with problem statement, approach, and solution link (via create-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/45&amp;diff=30594&amp;oldid=prev"/>
		<updated>2026-06-16T14:30:47Z</updated>

		<summary type="html">&lt;p&gt;Create Project Euler/45 page with problem statement, approach, and solution link (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;==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Shape !! Formula !! First Terms&lt;br /&gt;
|-&lt;br /&gt;
| Triangle || &amp;lt;math&amp;gt;T_n = \frac{1}{2} n (n + 1)&amp;lt;/math&amp;gt; || 1, 3, 6, 10, 15, ...&lt;br /&gt;
|-&lt;br /&gt;
| Pentagonal || &amp;lt;math&amp;gt;P_n = \frac{1}{2} n (3n - 1)&amp;lt;/math&amp;gt; || 1, 5, 12, 22, 35, ...&lt;br /&gt;
|-&lt;br /&gt;
| Hexagonal || &amp;lt;math&amp;gt;H_n = n (2n - 1)&amp;lt;/math&amp;gt; || 1, 6, 15, 28, 45, ...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It can be verified that &amp;lt;math&amp;gt;T_{285} = P_{165} = H_{143} = 40755&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Find the next triangle number that is also pentagonal and hexagonal.&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
===Key Insight: Hexagonal Numbers are Triangle Numbers===&lt;br /&gt;
&lt;br /&gt;
Every hexagonal number is also a triangle number. Algebraically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;H_n = n(2n - 1) = \frac{(2n-1)(2n)}{2} = T_{2n-1}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This means the problem reduces to finding the next hexagonal number (after H&amp;lt;sub&amp;gt;143&amp;lt;/sub&amp;gt; = 40755) that is also pentagonal. We only need to generate hexagonal numbers and test them for pentagonality.&lt;br /&gt;
&lt;br /&gt;
===Testing for Pentagonal Numbers===&lt;br /&gt;
&lt;br /&gt;
Given an integer &amp;#039;&amp;#039;x&amp;#039;&amp;#039;, we can test whether it is pentagonal by solving the quadratic derived from the pentagonal formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;P_n = \frac{n(3n - 1)}{2} \implies 3n^2 - n - 2x = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The discriminant is &amp;lt;math&amp;gt;1 + 24x&amp;lt;/math&amp;gt;. If &amp;#039;&amp;#039;x&amp;#039;&amp;#039; is pentagonal, then:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;s = \sqrt{1 + 24x}&amp;lt;/math&amp;gt; must be an integer (a perfect square), &amp;#039;&amp;#039;and&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;lt;math&amp;gt;(s + 1) \bmod 6 = 0&amp;lt;/math&amp;gt; (ensuring the root &amp;#039;&amp;#039;n&amp;#039;&amp;#039; is an integer).&lt;br /&gt;
&lt;br /&gt;
Both conditions are checked in one pass for each candidate.&lt;br /&gt;
&lt;br /&gt;
===Iteration Strategy===&lt;br /&gt;
&lt;br /&gt;
# Start with &amp;lt;math&amp;gt;n = 144&amp;lt;/math&amp;gt; (the next hexagonal index after 143, the known match).&lt;br /&gt;
# Compute the hexagonal number &amp;lt;math&amp;gt;H_n = n(2n - 1)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Test whether &amp;lt;math&amp;gt;H_n&amp;lt;/math&amp;gt; is pentagonal using the two conditions above.&lt;br /&gt;
# If it is pentagonal, this is the answer. Otherwise, increment &amp;#039;&amp;#039;n&amp;#039;&amp;#039; and repeat.&lt;br /&gt;
&lt;br /&gt;
Because every hexagonal number is already triangle, no separate triangle check is needed.&lt;br /&gt;
&lt;br /&gt;
==Solution==&lt;br /&gt;
&lt;br /&gt;
Link: https://git.charlesreid1.com/cs/euler/src/branch/main/java/Problem045.java&lt;br /&gt;
&lt;br /&gt;
==Flags==&lt;br /&gt;
&lt;br /&gt;
{{ProjectEulerFlag}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>