<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">My solution to Euler #12 runs in less than 1 minute.<br><br></font></div>
<p style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">Let us list the factors of the first eight triangle numbers:</font></p>
<blockquote style="font-size: 12pt; font-family: courier new;">
<p><font color="#000000"><b> 1</b>: 1<br><b> 3</b>: 1,3<br><b> 6</b>: 1,<u>2,3</u>,6<br><b>10</b>: 1,<u>2,5</u>,10<br><b>15</b>: 1,<u>3,5</u>,15<br><b>21</b>: 1,<u>3,7</u>,21<br><b>28</b>: 1,2,<u>4,7</u>,14,28</font></p>
<p><font color="#000000">36: 1,2,3,4,<u>6</u>,8,9,12,18,36</font></p></blockquote>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">Note the numbers that are underlined in each sequence. This is the half way point. </font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">a) If you divide the triangle number by the first number that is underlined the result will be greater than the divisor.</font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">b)
On the other hand if you divide the triangle number by the second
number that is underlined the result will be less than the divisor.</font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">c)
The triangle number 36 has only one number at the centre of the
sequence, because that centre number is the square root of the triangle
number 36.</font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"> </div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">In
cases a) and b) if you wanted to know the total number of divisors, you
look for the position of the number underlined as described in b), then
subtract 1 from it, then multiply it by 2. For example, for triangle
number 28, value 7 is in position 4. So (4-1) * 2 = 6</font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"> </div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">In
cases c) if you wanted to know the total number of divisors, you look
for the position of the center number underlined, then multiply it by
2. For example, for triangle number 36, value 6 is in position 5. </font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000">So 5</font><font color="#000000"> * 2 = 10</font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font color="#000000"><br>Here is the program.<br></font></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"> </div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font size="2">
</font><p><font color="#0000ff">Dim</font> triagNo <font color="#0000ff">As</font> <font color="#0000ff">Integer</font> <font color="#008000">' Triangle number</font></p>
<p><font color="#0000ff">Dim</font> counter <font color="#0000ff">As</font> <font color="#0000ff">Integer</font> <font color="#008000">' for calculating the next triangle number</font></p>
<p><font color="#0000ff">Dim</font> varValue <font color="#0000ff">As</font> <font color="#0000ff">Integer </font> <font color="#008000">' Incremented in search for a <span style="border-bottom: 1px dashed rgb(0, 102, 204); cursor: pointer;" class="yshortcuts" id="lw_1215872011_0">Divisor</span></font></p>
<p><font color="#0000ff">Dim</font> NoDivisors <font color="#0000ff">As</font> <font color="#0000ff">Integer</font> <font color="#008000">' number of Divisors found</font></p>
<p><font color="#0000ff">Dim</font> Divisor <font color="#0000ff">As</font> <font color="#0000ff">Integer</font> <font color="#008000">' Value of found Divisor</font></p>
<p><font color="#008000"> </font></p>
<p><font color="#0000ff">Do</font></p>
<p> counter += 1</p>
<p> triagNo = triagNo + counter</p>
<p> varValue = 0</p>
<p> Divisor = 0</p>
<p> NoDivisors = 0</p>
<p> </p>
<p><font color="#0000ff"> Do</font></p>
<p> varValue += 1</p>
<p><font color="#0000ff"> If</font> triagNo <font color="#0000ff">Mod</font> varValue = 0 <font color="#0000ff">Then</font> <font color="#008000">' is varValue a Divisor</font></p>
<p> Divisor = varValue</p>
<p> NoDivisors += 1</p>
<p><font color="#0000ff"> End</font> <font color="#0000ff">If</font></p>
<p><font color="#0000ff"> Loop</font> <font color="#0000ff">Until</font> (triagNo / Divisor) <= Divisor <font color="#008000">' Find when you reach the second centre value </font></p>
<p><font color="#008000"> </font></p>
<p><font color="#0000ff"> If</font> (triagNo / Divisor) = Divisor <font color="#0000ff">Then</font></p>
<p> NoDivisors = (NoDivisors - 1) * 2 + 1 <font color="#008000">' cases a) and b)</font></p>
<p><font color="#0000ff"> Else</font></p>
<p> NoDivisors = (NoDivisors - 1) * 2 <font color="#008000">' case c) </font></p>
<p><font color="#0000ff"> End</font> <font color="#0000ff">If</font></p>
<p><font color="#0000ff"> </font></p>
<p><font color="#0000ff">Loop</font> <font color="#0000ff">Until</font> (NoDivisors > 500)</p>
<p> </p>
<p>TextBox1.Text = triagNo</p><br><p><br></p><p>Z. Mwangi<br></p></div><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Andrew Mathenge <mathenge@gmail.com><br>To: ubuntu Kenya <ubuntu-ke@lists.ubuntu.com><br>Sent: Friday, July 11, 2008 3:24:23 AM<br>Subject: Re: Euler Problems<br><br>
This email is from a ubuntu-ke subscriber to other subscribers inluding you:)<br>I've been working on #12 and the performance is simply not acceptable.<br>Has anyone been able to get this running as fast as some of the posts<br>on the site claim?<br><br>Andrew.<br><br>On Tue, Jul 8, 2008 at 12:40 PM, kinuthiA muchanE <<a ymailto="mailto:muchanek@gmail.com" href="mailto:muchanek@gmail.com">muchanek@gmail.com</a>> wrote:<br>> Andrew,<br>> For #10, if you do not use a sieve to find the primes, it will run<br>> forever!<br>> There is one called the Sieve of Erastothenes. Check it out on<br>> <a target="_blank" href="http://www.wikipedia.org/">Wikipedia</a>.<br>><br>> Good luck :-)<br>> Kinuthia...<br>> On Tue, 2008-07-08 at 10:47 -0400, Andrew Mathenge wrote:<br>>> I'm still trying them. I started at #1 after the one you proposed<br>>> (#26) and I'm at #10 now. This one should be very simple but I
don't<br>>> know why it's taking so long to run.<br>>><br>>> Andrew.<br>>><br>>> On Tue, Jul 8, 2008 at 6:52 AM, kinuthiA muchanE <<a ymailto="mailto:muchanek@gmail.com" href="mailto:muchanek@gmail.com">muchanek@gmail.com</a>> wrote:<br>>> > Habari,<br>>> > Anybody still trying these problems, you are all so, so silent...<br>>> ><br>>> > Kinuthia...<br>>> ><br>>> ><br>><br>><br><br>-- <br>Ubuntu-ke mailing list<br><a ymailto="mailto:Ubuntu-ke@lists.ubuntu.com" href="mailto:Ubuntu-ke@lists.ubuntu.com">Ubuntu-ke@lists.ubuntu.com</a><br><a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-ke" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-ke</a><br></div></div></div><br>
</body></html>