<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jesse Briggs</title>
	<atom:link href="http://jessebriggs.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://jessebriggs.net</link>
	<description></description>
	<lastBuildDate>Sun, 20 May 2012 06:04:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Graduation</title>
		<link>http://jessebriggs.net/graduation/</link>
		<comments>http://jessebriggs.net/graduation/#comments</comments>
		<pubDate>Sun, 20 May 2012 06:04:33 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=221</guid>
		<description><![CDATA[I went to a high-school graduation today. I&#8217;ve been to several, and they all seem the same. (Bad) Attempts at inspirational speeches, self-deprecating humor about kindergarten-til-now experiences, self-back-patting. Tonight I heard &#8220;amazing accomplishment&#8221; and &#8220;incredibly proud&#8221; so many times I want to vomit. Why are we teaching our young people that graduating high-school is something [...]]]></description>
			<content:encoded><![CDATA[<p>I went to a high-school graduation today. I&#8217;ve been to several, and they all seem the same. (Bad) Attempts at inspirational speeches, self-deprecating humor about kindergarten-til-now experiences, self-back-patting.</p>
<p>Tonight I heard &#8220;amazing accomplishment&#8221; and &#8220;incredibly proud&#8221; so many times I want to vomit. Why are we teaching our young people that graduating high-school is something to be proud of? It&#8217;s the de-facto. It&#8217;s not even mediocre&#8211;even sub-mediocre students mostly graduate. If we expect everyone to graduate, what is there to be proud of?</p>
<p>They also talked a lot about the end of one &#8220;life&#8221; or phase, and the beginning of &#8220;the rest of their lives.&#8221; Mostly that will probably entail an entry into the workforce, and feeble attempts at the more widespread version of the American dream&#8211;college, a house, and a new car. Gross.</p>
<p>One speech stood out tonight. A bright young lady gave a nice performance, and talked about how everyone is authoring their own story&#8211;each story unique, with its own heroes and villains. I like the idea of that. I think the goal is to make your story one worth reading. Exciting, full of twists, heroes pursuing dreams and vanquishing villains.</p>
<p>If that&#8217;s not the plan, what is?</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/graduation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Skills, My Strengths, My Weaknesses</title>
		<link>http://jessebriggs.net/my-skills-strengths-weaknesses/</link>
		<comments>http://jessebriggs.net/my-skills-strengths-weaknesses/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 05:31:59 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=207</guid>
		<description><![CDATA[I&#8217;m beginning to actively seek a job/internship/mentor as a (Python) developer. To be forthcoming, I&#8217;m outlining my ability here. I think I&#8217;m a good fit for some roles and not for others. I haven&#8217;t been able to talk shop with many developers and it&#8217;s hard to find metrics to measure yourself by in the coding [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m beginning to actively seek a job/internship/mentor as a (Python) developer. To be forthcoming, I&#8217;m outlining my ability here. I think I&#8217;m a good fit for some roles and not for others. I haven&#8217;t been able to talk shop with many developers and it&#8217;s hard to find metrics to measure yourself by in the coding world&#8211;mostly it seems like you just make something and get noticed for it.</p>
<p>I see a lot of jobs asking for &#8220;brilliant,&#8221; &#8220;amazing&#8221; developers. I&#8217;ve had my IQ professionally-assessed and I&#8217;m not embarrassed of it, but I don&#8217;t &#8220;own&#8221; brilliance. I&#8217;m smart, and I&#8217;m determined. I stick with problems. I&#8217;m not always brilliant, but I get it done.</p>
<p>&nbsp;</p>
<h3>General Programming</h3>
<p>I can make things. I&#8217;ve made lots of  CRUD apps. I&#8217;ve never moved sprites around the screen, but I can learn, quickly. I&#8217;ve done the first 50 Project Euler problems. My code is pretty clean. My app structure is probably not, unless required by frameworks. I like small, readable functions. My git skills are rudimentary. I love optimizing and clever code, but I&#8217;m not real familiar with &#8220;big O&#8221; and the like. My optimization is on a smaller, &#8220;common-sense and small improvements&#8221; scale. I haven&#8217;t done social integration, or worked with any 3rd-party APIs, but I think I&#8217;m already capable. I have to reference docs a lot. I don&#8217;t mind referencing docs. I&#8217;m a stickler for details. I can do FizzBuzz. I read programming blogs (love codinghorror, codingthewheel among others). I click virtually every Python link that makes HN. I read stackoverflow in my spare time for fun.</p>
<p>I currently code in a Linux environment, Vim (with very few mods) being my editor of choice.</p>
<p>Generally speaking, I&#8217;m no world-beater, but with less three months of full-time coding, I feel I&#8217;ll be a strong player in a web-app environment.</p>
<p>Here are some paragraphs being more specific:</p>
<h3>Python</h3>
<p>I&#8217;ve been coding in python for a few years now, however not in any real serious capacity. I&#8217;ve done a couple of trivial desktop applications using Tkinter and a couple of decently-sized web apps, mostly CRUD apps. I spent quite a while working on a port of an existing mess of disgusting code from PHP to Python, before I parted ways with the company. I&#8217;m no prodigy, and I have to reference docs a lot, but more exposure will definitely fix that. I can get things done, I just might take a while. I&#8217;ve completed the first 50 (and a handful of other) Project Euler problems in Python. For many of them I&#8217;ve done several versions, delving into optimization of my algorithms. I like to think I&#8217;m employable&#8211;I&#8217;m no lead/senior developer, but I can hack away at the small stuff. I&#8217;d love an entry-level job, and I&#8217;m certain my skill will increase to a high level in a short period of time. My very favorite feature is list comprehension. I like &#8220;one obvious way.&#8221; I think Python code can be beautiful in ways that other languages can&#8217;t replicate.</p>
<h3>Django</h3>
<p>Quite related to my Python entry above, but I&#8217;ve done a few trivial web apps in Django. I understand the basic flow of things, though I haven&#8217;t delved too deeply into things like middleware except when requirements led me there. Most of my web development happened in PHP prior to me being exposed to any frameworks. When I found them, I found Django first. It compelled me to learn Python because I was so taken with the idea&#8211;frameworks make me warm and fuzzy inside. I love the structure, I love having the basic outline of &#8220;what goes where&#8221; planned and accounted for ahead of time.</p>
<p>http://husng.sejje.net/ is a simple poker tool that I wrote using Python/Django.</p>
<h3>Version Control</h3>
<p>I have limited experience with Mercurial and Git. Limited in the sense that I&#8217;ve just used them for a couple of small personal projects, to learn them. I&#8217;ve never deployed with them, nor managed a complex app. I&#8217;ve been a linux user for over a decade, though, so I don&#8217;t have any problem adapting to command-line tools. I just need some hands-on to become more familiar, and probably a few minutes to add some aliases to my bashrc.</p>
<h3>HTML/CSS</h3>
<p>Self-taught HTML while in high-school. This was in 2000-2001, when people used frames and tables for layouts, and iframes were just becoming popular. CSS came later, and to me was an amazing gift bestowed by geniuses&#8211;it was the same feeling as when I first found php, so that I didn&#8217;t have to maintain a layout/menu in 25 separate HTML files. Design is not my forte, however. My HTML/CSS tends to be extremely functional: display the info in a more-or-less readable fashion. I grok HTML, and old CSS. All the new stuff, though&#8211;HTML5, CSS3&#8211;is relatively unknown to me. I can hack it together, but this is not my main interest. The box model is my arch-enemy, it never just goes where I want it.</p>
<h3>PHP</h3>
<p>I found PHP directly after I ported my site to use server-side-includes. I was so amazed that I immediately commenced an entire rewrite of my website. Databases were extremely powerful and superior to file-based-storage in so many ways. I&#8217;ve seen a LOT of php code, and coded 10+ CRUD apps using it&#8211;all relatively small by today&#8217;s standards. One site used CodeIgniter, though I feel I&#8217;m more competent than that might show&#8211;I have some experience with non-PHP frameworks, so I mostly &#8220;get it.&#8221; I haven&#8217;t used PHP much in the last couple of years, so it&#8217;s possible that my knowledge is lagging some, and I&#8217;ll be rusty with syntax.</p>
<p>One of my PHP sites is up at <a href="http://lmfao.us/">http://lmfao.us/</a>, though I have no control over it any longer as my partner died quite a while ago and although someone (unknown to me) is renewing the domain (he controls it), the site is just languishing. It has auto-thumbnailing (intervention optional) and watermarking in the admin panel.</p>
<h3>MySQL</h3>
<p>I&#8217;ve used MySQL in quite a lot of projects, but they were all CRUD and had no use for scaling. I&#8217;m functional for sure, but I&#8217;m not knowledgeable in any advanced SQL. My SQL looks mostly like this:<br />
&#8220;SELECT user, id FROM users WHERE location=&#8217;USA&#8217;&#8221;</p>
<p>I&#8217;m not able to troubleshoot MySQL performance issues beyond common sense: make fewer calls, use Google. Like anything else, though, I can learn this quickly&#8211;it has just never been necessary.</p>
<p>For two years all of my exposure to MySQL or any database has been abstracted through the Django ORM, so I&#8217;m pretty rusty at raw SQL.</p>
<p>&nbsp;</p>
<h3>Strengths:</h3>
<p>I learn quickly, and thoroughly.<br />
I like to understand how things work, which leads to intricate knowledge.<br />
I&#8217;m smart.<br />
I express my thoughts well, in both written and oral language.<br />
I mesh well.<br />
I have essentially zero worldly obligations, excepting a girl I can&#8217;t be without. No pets, kids, debts, homes.<br />
I like hard problems.<br />
I have staying power, I stick with problems.<br />
I love coding.<br />
I have opinions.<br />
My word is good.<br />
Passion comes easy.<br />
I like good music.</p>
<p>&nbsp;</p>
<h3>Weaknesses:</h3>
<p>I can&#8217;t design.<br />
I can&#8217;t even match my clothes, except by rules I&#8217;ve been taught.<br />
I avoid confrontation, sometimes at the expense of something important.<br />
I don&#8217;t know Apple.<br />
I&#8217;m not &#8220;colleged.&#8221;<br />
I sleep a lot.<br />
I hate voice calls.<br />
I don&#8217;t like beer (but can definitely handle a mixed drink), coffee, energy drinks.<br />
You sometimes have to dig for my opinions.<br />
I miss pop-culture references.<br />
Floating the box model.</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/my-skills-strengths-weaknesses/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accept.</title>
		<link>http://jessebriggs.net/accept/</link>
		<comments>http://jessebriggs.net/accept/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 02:46:40 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=209</guid>
		<description><![CDATA[I keep looking for meaning, but all I&#8217;ve found so far is that in order to be at peace with the present, we must be at peace with the past, because the present is a product of the past. Accept. Accept. Accept. Learn to love the present moment. What happened, happened. It&#8217;s difficult to understand [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
I keep looking for meaning, but all I&#8217;ve found so far is that in order to be at peace with the present, we must be at peace with the past, because the present is a product of the past. Accept. Accept. Accept. Learn to love the present moment. What happened, happened. It&#8217;s difficult to understand the big picture when our lives are mere brush strokes on the canvas of reality. Trusting that it all fits together to form something beautiful is the purest form of faith. Anything else is a dangerous distraction. No contracts with God, no expectations of reward, just trust.
</p></blockquote>
<p>&#8212;<a href="http://paulbuchheit.blogspot.com/2012/03/eight-years-today.html">Paul Buchheit</a></p>
<p>And that&#8217;s where I am. I have my hopes set high, and I&#8217;m not prepared for failure. But here, now, in this moment, I have to accept the path that led me here. I&#8217;m undeniably here. I want to rise like a phoenix from these ashes, carrying my prize with me. Able to because of my new-found strength. But I&#8217;m just choking on the ashes, floundering.</p>
<p>But I think that the ashes in the air will subside. Things will be beautiful, because we went down this path for a reason. Unbeknownst to us, something beautiful is being painted. I can&#8217;t wait to see it, quite literally&#8211;my innards twist in ways I&#8217;ve never known, in anticipation and at the memory of their own shortcomings. But my new-found strength comes from them&#8211;my heart works in ways it never worked before. And in that terrible pain it can now feel comes its salvation&#8211;it has become what was needed all along.</p>
<p>I pray the ashes will subside. I want to push into the sunlight.</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/accept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Development as a Developer</title>
		<link>http://jessebriggs.net/my-development-as-a-developer/</link>
		<comments>http://jessebriggs.net/my-development-as-a-developer/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 23:11:15 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=203</guid>
		<description><![CDATA[tl;dr: I&#8217;m mostly a hobbyist. I&#8217;ve made a couple of &#8220;application&#8221;-sized websites with HTML/CSS/PHP/Python/MySQL. I&#8217;ve made a lot of little &#8220;tools&#8221; with GUIs for windows. I taught myself all of it, and so in many areas I know just as much as I need to. I&#8217;ve been coding a long time, but never in an [...]]]></description>
			<content:encoded><![CDATA[<p>tl;dr:<br />
I&#8217;m mostly a hobbyist. I&#8217;ve made a couple of &#8220;application&#8221;-sized websites with HTML/CSS/PHP/Python/MySQL. I&#8217;ve made a lot of little &#8220;tools&#8221; with GUIs for windows. I taught myself all of it, and so in many areas I know just as much as I need to.</p>
<p>I&#8217;ve been coding a long time, but never in an overly-serious sense. I like to make things, or I have an idea that I want to pursue that requires some coding. But it goes way back.</p>
<p>My first computer experience was on a DOS/Win 3.1 system when I was maybe 10. It was my older sister&#8217;s, and she didn&#8217;t know much about it. It had basic and a few games, and I inspected them and found out roughly how they worked. I don&#8217;t have what I made, but I remember lots of GOTOs. I liked text-adventure games (Zork), and tried to replicate those. But I only had access in the summer, and I also had Doom distracting me.</p>
<p>Fast-forward six years and I get my first computer around age 16. I had been on AOL with some buddies and already knew that I wanted a punter, and a chatcom, and whatever. I found my way into the &#8220;vb6&#8243; chat, and eventually acquired dos32.bas. I made a lot of dinky little programs. An mp3 player (with a custom shape, not square), an &#8220;AIM bank&#8221; to store all of my AIM handles, a chat-com, etc. I was fascinated by sub7, and learned sockets and made a similar remote-control type client/server. Later I found out about affiliate marketing, and to make a long story short, I made a chatlinker (it spammed my link) and a really non-obtrusive website that mostly didn&#8217;t get me flagged for spam. I made probably $6500 in my junior year of high-school. </p>
<p>Somewhere in that same time-span I made an angelfire-hosted Goldeneye fansite. I taught myself HTML in a couple of weeks. Back then frames were all the rage. Animated gifs, hit counters, &#8220;guestbooks.&#8221; I eventually made a personal site. Now it&#8217;d be considered a blog, but back then we called them &#8220;Everything/nothing.&#8221; I learned about server-side-includes, and they blew my mind. And about a week after I finished implementing them, I learned about PHP&#8211;it was pretty new. I rewrote my whole site, and used a site called gyrate.org as inspiration. I made a user-system, where users could earn points by contributions&#8211;comments, votes, etc. They could spend points on things like front-page posts. I also had a &#8220;neverending story,&#8221; which was like a choose-your-own-adventure story, but if you came to a dead-end you could write a page in the book. I had a pretty active userbase of around 300 people, until my domain was squatted. </p>
<p>For a large period of this time, I used linux as my main desktop OS. I started in Mandrake, mostly used Debian, and eventually moved to Ubuntu and now Arch. I wrote some shell scripts and learned some basic sysadmin. I set up my own LAMP stack, got a DNS server up, mail server, etc.</p>
<p>I got away from coding at this point, but I would still sometimes find a reason to start a project. I played professional poker, and I made a program that would automatically seek out bad players and sit in their games (but I played manually). It interfaced with the Full Tilt Poker client, and looked players up on Sharkscope, scraping their stats out of the JSON.</p>
<p>Another project was a funny image site. Initially coded in PHP/MySQL, re-wrote later in PHP using CodeIgniter. I later started a Python/Django rewrite for fun, but never finished.</p>
<p>Since then I&#8217;ve worked on a few smallish projects, but still nothing very serious. I&#8217;ve had some ideas for startups, and I&#8217;ve done some workups in Python/Django. I love Django and basically everything about it. Frameworks would have kept me developing nonstop&#8211;they take away so much of what was boring to me about developing.</p>
<p>I&#8217;ve done a lot of Project Euler problems&#8211;I enjoy them, they&#8217;re like logic puzzles, and they&#8217;re teaching me a lot of new python concepts as well.</p>
<p>I&#8217;m trying to push my skills to &#8220;employable&#8221; and work on a project I love.</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/my-development-as-a-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 13 in Python</title>
		<link>http://jessebriggs.net/project-euler-problem-13-in-python/</link>
		<comments>http://jessebriggs.net/project-euler-problem-13-in-python/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 21:48:53 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=200</guid>
		<description><![CDATA[Problem 13 requests: Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. &#8230; Some euler problems almost look like programming exercises. There&#8217;s nothing special about this problem whatsoever, it feels like a basic file-reading exercise. So, I stored the numbers in a file. Opening files in python is pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Problem 13 requests:</p>
<blockquote><p>
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.</p>
<p>&#8230;
</p></blockquote>
<p>Some euler problems almost look like programming exercises. There&#8217;s nothing special about this problem whatsoever, it feels like a basic file-reading exercise.</p>
<p>So, I stored the numbers in a file.</p>
<p>Opening files in python is pretty simple:</p>
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_lshaJL  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_lshaJL .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_lshaJLtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_lshaJLtable td, .pygmentize_lshaJLtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_lshaJL pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_lshaJL {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_lshaJL {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_lshaJL td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_lshaJL .hll { background-color: #ffffcc }
.pygmentize_lshaJL  { background: #f8f8f8; }
.pygmentize_lshaJL .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_lshaJL .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_lshaJL .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_lshaJL .o { color: #666666 } /* Operator */
.pygmentize_lshaJL .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_lshaJL .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_lshaJL .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_lshaJL .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_lshaJL .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_lshaJL .ge { font-style: italic } /* Generic.Emph */
.pygmentize_lshaJL .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_lshaJL .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_lshaJL .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_lshaJL .go { color: #808080 } /* Generic.Output */
.pygmentize_lshaJL .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_lshaJL .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_lshaJL .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_lshaJL .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_lshaJL .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_lshaJL .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_lshaJL .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_lshaJL .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_lshaJL .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_lshaJL .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_lshaJL .m { color: #666666 } /* Literal.Number */
.pygmentize_lshaJL .s { color: #BA2121 } /* Literal.String */
.pygmentize_lshaJL .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_lshaJL .nb { color: #008000 } /* Name.Builtin */
.pygmentize_lshaJL .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_lshaJL .no { color: #880000 } /* Name.Constant */
.pygmentize_lshaJL .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_lshaJL .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_lshaJL .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_lshaJL .nf { color: #0000FF } /* Name.Function */
.pygmentize_lshaJL .nl { color: #A0A000 } /* Name.Label */
.pygmentize_lshaJL .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_lshaJL .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_lshaJL .nv { color: #19177C } /* Name.Variable */
.pygmentize_lshaJL .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_lshaJL .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_lshaJL .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_lshaJL .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_lshaJL .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_lshaJL .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_lshaJL .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_lshaJL .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_lshaJL .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_lshaJL .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_lshaJL .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_lshaJL .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_lshaJL .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_lshaJL .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_lshaJL .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_lshaJL .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_lshaJL .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_lshaJL .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_lshaJL .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_lshaJL .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_lshaJL .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_lshaJL .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_lshaJL"><pre><span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s">&#39;13-numbers.txt&#39;</span><span class="p">,</span> <span class="s">&#39;r&#39;</span><span class="p">)</span>
</pre></div>


<p>The &#8216;r&#8217; just means &#8220;open for reading.&#8221;</p>
<p>Then you can loop over the lines like this:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_xDMJJS  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_xDMJJS .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_xDMJJStable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_xDMJJStable td, .pygmentize_xDMJJStable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_xDMJJS pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_xDMJJS {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_xDMJJS {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_xDMJJS td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_xDMJJS .hll { background-color: #ffffcc }
.pygmentize_xDMJJS  { background: #f8f8f8; }
.pygmentize_xDMJJS .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_xDMJJS .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_xDMJJS .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_xDMJJS .o { color: #666666 } /* Operator */
.pygmentize_xDMJJS .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_xDMJJS .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_xDMJJS .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_xDMJJS .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_xDMJJS .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_xDMJJS .ge { font-style: italic } /* Generic.Emph */
.pygmentize_xDMJJS .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_xDMJJS .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_xDMJJS .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_xDMJJS .go { color: #808080 } /* Generic.Output */
.pygmentize_xDMJJS .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_xDMJJS .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_xDMJJS .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_xDMJJS .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_xDMJJS .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_xDMJJS .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_xDMJJS .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_xDMJJS .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_xDMJJS .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_xDMJJS .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_xDMJJS .m { color: #666666 } /* Literal.Number */
.pygmentize_xDMJJS .s { color: #BA2121 } /* Literal.String */
.pygmentize_xDMJJS .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_xDMJJS .nb { color: #008000 } /* Name.Builtin */
.pygmentize_xDMJJS .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_xDMJJS .no { color: #880000 } /* Name.Constant */
.pygmentize_xDMJJS .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_xDMJJS .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_xDMJJS .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_xDMJJS .nf { color: #0000FF } /* Name.Function */
.pygmentize_xDMJJS .nl { color: #A0A000 } /* Name.Label */
.pygmentize_xDMJJS .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_xDMJJS .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_xDMJJS .nv { color: #19177C } /* Name.Variable */
.pygmentize_xDMJJS .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_xDMJJS .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_xDMJJS .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_xDMJJS .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_xDMJJS .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_xDMJJS .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_xDMJJS .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_xDMJJS .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_xDMJJS .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_xDMJJS .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_xDMJJS .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_xDMJJS .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_xDMJJS .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_xDMJJS .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_xDMJJS .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_xDMJJS .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_xDMJJS .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_xDMJJS .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_xDMJJS .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_xDMJJS .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_xDMJJS .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_xDMJJS .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_xDMJJS"><pre><span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">num</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
</pre></div>

</p>
<p>In this case, the line is a 50-digit number (that python still things is a string, so we convert with int() ).</p>
<p>Sum up all the numbers, and then to find the first ten digits you convert back to string and use a splice:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_DNjO0Z  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_DNjO0Z .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_DNjO0Ztable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_DNjO0Ztable td, .pygmentize_DNjO0Ztable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_DNjO0Z pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_DNjO0Z {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_DNjO0Z {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_DNjO0Z td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_DNjO0Z .hll { background-color: #ffffcc }
.pygmentize_DNjO0Z  { background: #f8f8f8; }
.pygmentize_DNjO0Z .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_DNjO0Z .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_DNjO0Z .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_DNjO0Z .o { color: #666666 } /* Operator */
.pygmentize_DNjO0Z .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_DNjO0Z .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_DNjO0Z .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_DNjO0Z .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_DNjO0Z .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_DNjO0Z .ge { font-style: italic } /* Generic.Emph */
.pygmentize_DNjO0Z .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_DNjO0Z .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_DNjO0Z .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_DNjO0Z .go { color: #808080 } /* Generic.Output */
.pygmentize_DNjO0Z .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_DNjO0Z .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_DNjO0Z .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_DNjO0Z .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_DNjO0Z .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_DNjO0Z .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_DNjO0Z .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_DNjO0Z .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_DNjO0Z .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_DNjO0Z .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_DNjO0Z .m { color: #666666 } /* Literal.Number */
.pygmentize_DNjO0Z .s { color: #BA2121 } /* Literal.String */
.pygmentize_DNjO0Z .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_DNjO0Z .nb { color: #008000 } /* Name.Builtin */
.pygmentize_DNjO0Z .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_DNjO0Z .no { color: #880000 } /* Name.Constant */
.pygmentize_DNjO0Z .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_DNjO0Z .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_DNjO0Z .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_DNjO0Z .nf { color: #0000FF } /* Name.Function */
.pygmentize_DNjO0Z .nl { color: #A0A000 } /* Name.Label */
.pygmentize_DNjO0Z .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_DNjO0Z .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_DNjO0Z .nv { color: #19177C } /* Name.Variable */
.pygmentize_DNjO0Z .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_DNjO0Z .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_DNjO0Z .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_DNjO0Z .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_DNjO0Z .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_DNjO0Z .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_DNjO0Z .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_DNjO0Z .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_DNjO0Z .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_DNjO0Z .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_DNjO0Z .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_DNjO0Z .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_DNjO0Z .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_DNjO0Z .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_DNjO0Z .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_DNjO0Z .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_DNjO0Z .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_DNjO0Z .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_DNjO0Z .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_DNjO0Z .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_DNjO0Z .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_DNjO0Z .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_DNjO0Z"><pre><span class="nb">str</span><span class="p">(</span><span class="n">total</span><span class="p">)[</span><span class="mi">0</span><span class="p">:</span><span class="mi">10</span><span class="p">]</span>
</pre></div>

</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/project-euler-problem-13-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 12 in Python</title>
		<link>http://jessebriggs.net/project-euler-problem-12-in-python/</link>
		<comments>http://jessebriggs.net/project-euler-problem-12-in-python/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 20:57:38 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=192</guid>
		<description><![CDATA[Project Euler Problem 12 deals with factorization, so it&#8217;s important to get a pretty efficient function to do that. The problem reads: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = [...]]]></description>
			<content:encoded><![CDATA[<p>Project Euler Problem 12 deals with factorization, so it&#8217;s important to get a pretty efficient function to do that. The problem reads:</p>
<blockquote><p>
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:</p>
<p>1, 3, 6, 10, 15, 21, 28, 36, 45, 55, &#8230;</p>
<p>Let us list the factors of the first seven triangle numbers:</p>
<p> 1: 1<br />
 3: 1,3<br />
 6: 1,2,3,6<br />
10: 1,2,5,10<br />
15: 1,3,5,15<br />
21: 1,3,7,21<br />
28: 1,2,4,7,14,28<br />
We can see that 28 is the first triangle number to have over five divisors.</p>
<p>What is the value of the first triangle number to have over five hundred divisors?
</p></blockquote>
<p>So, I created a &#8220;factor&#8221; function that returns all the factors of a given number. I&#8217;ll save you the trouble of finding it later, and let you know that this is a useful function (for Euler) that should be put in your re-usable toolbelt&#8211;in my case, euler.py.</p>
<p>Here&#8217;s my most efficient example:</p>
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_NfplA7  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_NfplA7 .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_NfplA7table {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_NfplA7table td, .pygmentize_NfplA7table th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_NfplA7 pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_NfplA7 {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_NfplA7 {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_NfplA7 td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_NfplA7 .hll { background-color: #ffffcc }
.pygmentize_NfplA7  { background: #f8f8f8; }
.pygmentize_NfplA7 .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_NfplA7 .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_NfplA7 .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_NfplA7 .o { color: #666666 } /* Operator */
.pygmentize_NfplA7 .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_NfplA7 .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_NfplA7 .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_NfplA7 .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_NfplA7 .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_NfplA7 .ge { font-style: italic } /* Generic.Emph */
.pygmentize_NfplA7 .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_NfplA7 .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_NfplA7 .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_NfplA7 .go { color: #808080 } /* Generic.Output */
.pygmentize_NfplA7 .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_NfplA7 .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_NfplA7 .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_NfplA7 .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_NfplA7 .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_NfplA7 .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_NfplA7 .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_NfplA7 .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_NfplA7 .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_NfplA7 .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_NfplA7 .m { color: #666666 } /* Literal.Number */
.pygmentize_NfplA7 .s { color: #BA2121 } /* Literal.String */
.pygmentize_NfplA7 .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_NfplA7 .nb { color: #008000 } /* Name.Builtin */
.pygmentize_NfplA7 .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_NfplA7 .no { color: #880000 } /* Name.Constant */
.pygmentize_NfplA7 .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_NfplA7 .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_NfplA7 .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_NfplA7 .nf { color: #0000FF } /* Name.Function */
.pygmentize_NfplA7 .nl { color: #A0A000 } /* Name.Label */
.pygmentize_NfplA7 .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_NfplA7 .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_NfplA7 .nv { color: #19177C } /* Name.Variable */
.pygmentize_NfplA7 .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_NfplA7 .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_NfplA7 .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_NfplA7 .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_NfplA7 .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_NfplA7 .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_NfplA7 .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_NfplA7 .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_NfplA7 .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_NfplA7 .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_NfplA7 .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_NfplA7 .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_NfplA7 .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_NfplA7 .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_NfplA7 .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_NfplA7 .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_NfplA7 .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_NfplA7 .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_NfplA7 .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_NfplA7 .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_NfplA7 .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_NfplA7 .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_NfplA7"><pre><span class="k">def</span> <span class="nf">factorize</span><span class="p">(</span><span class="n">num</span><span class="p">):</span>
    <span class="n">factors</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="n">num</span><span class="p">]</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">num</span><span class="p">))</span><span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">num</span> <span class="o">%</span> <span class="n">i</span><span class="p">:</span>
            <span class="n">factors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
            <span class="n">factors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">num</span> <span class="o">/</span> <span class="n">i</span><span class="p">)</span>
    <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">factors</span><span class="p">))</span>
</pre></div>


<p>So we fill the list with 1 and the number, and then check remainders with modulus (%) for all the other numbers up to the square root. That&#8217;s as far as we have to go, and we&#8217;ll use 36 as an example to see why:</p>
<p>start with [1, 36]<br />
check 2, find [2, 18]<br />
check 3, find [3, 12]<br />
check 4, find [4, 9]<br />
check 5, fail<br />
check 6, find [6]<br />
Done.</p>
<p>So even though we only went to six, we were able to get 9, 12, and 18&#8211;numbers greater than six. Any number greater than six will have a corresponding factor lower than six, so for max efficiency we don&#8217;t go any higher.</p>
<p>Moving on, it&#8217;s now a fairly simple matter to check each triangle number for X number of factors, in this case 500.</p>
<p>First, I imported my factorization function:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_LncFqf  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_LncFqf .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_LncFqftable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_LncFqftable td, .pygmentize_LncFqftable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_LncFqf pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_LncFqf {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_LncFqf {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_LncFqf td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_LncFqf .hll { background-color: #ffffcc }
.pygmentize_LncFqf  { background: #f8f8f8; }
.pygmentize_LncFqf .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_LncFqf .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_LncFqf .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_LncFqf .o { color: #666666 } /* Operator */
.pygmentize_LncFqf .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_LncFqf .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_LncFqf .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_LncFqf .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_LncFqf .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_LncFqf .ge { font-style: italic } /* Generic.Emph */
.pygmentize_LncFqf .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_LncFqf .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_LncFqf .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_LncFqf .go { color: #808080 } /* Generic.Output */
.pygmentize_LncFqf .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_LncFqf .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_LncFqf .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_LncFqf .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_LncFqf .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_LncFqf .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_LncFqf .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_LncFqf .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_LncFqf .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_LncFqf .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_LncFqf .m { color: #666666 } /* Literal.Number */
.pygmentize_LncFqf .s { color: #BA2121 } /* Literal.String */
.pygmentize_LncFqf .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_LncFqf .nb { color: #008000 } /* Name.Builtin */
.pygmentize_LncFqf .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_LncFqf .no { color: #880000 } /* Name.Constant */
.pygmentize_LncFqf .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_LncFqf .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_LncFqf .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_LncFqf .nf { color: #0000FF } /* Name.Function */
.pygmentize_LncFqf .nl { color: #A0A000 } /* Name.Label */
.pygmentize_LncFqf .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_LncFqf .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_LncFqf .nv { color: #19177C } /* Name.Variable */
.pygmentize_LncFqf .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_LncFqf .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_LncFqf .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_LncFqf .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_LncFqf .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_LncFqf .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_LncFqf .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_LncFqf .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_LncFqf .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_LncFqf .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_LncFqf .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_LncFqf .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_LncFqf .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_LncFqf .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_LncFqf .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_LncFqf .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_LncFqf .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_LncFqf .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_LncFqf .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_LncFqf .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_LncFqf .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_LncFqf .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_LncFqf"><pre><span class="kn">from</span> <span class="nn">euler</span> <span class="kn">import</span> <span class="n">factors</span>
</pre></div>

</p>
<p>Then I made a function to find the first (triangle) number with X number of factors:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_Pirvxn  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_Pirvxn .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_Pirvxntable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_Pirvxntable td, .pygmentize_Pirvxntable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_Pirvxn pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_Pirvxn {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_Pirvxn {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_Pirvxn td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_Pirvxn .hll { background-color: #ffffcc }
.pygmentize_Pirvxn  { background: #f8f8f8; }
.pygmentize_Pirvxn .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_Pirvxn .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_Pirvxn .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_Pirvxn .o { color: #666666 } /* Operator */
.pygmentize_Pirvxn .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_Pirvxn .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_Pirvxn .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_Pirvxn .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_Pirvxn .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_Pirvxn .ge { font-style: italic } /* Generic.Emph */
.pygmentize_Pirvxn .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_Pirvxn .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_Pirvxn .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_Pirvxn .go { color: #808080 } /* Generic.Output */
.pygmentize_Pirvxn .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_Pirvxn .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_Pirvxn .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_Pirvxn .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_Pirvxn .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_Pirvxn .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_Pirvxn .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_Pirvxn .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_Pirvxn .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_Pirvxn .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_Pirvxn .m { color: #666666 } /* Literal.Number */
.pygmentize_Pirvxn .s { color: #BA2121 } /* Literal.String */
.pygmentize_Pirvxn .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_Pirvxn .nb { color: #008000 } /* Name.Builtin */
.pygmentize_Pirvxn .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_Pirvxn .no { color: #880000 } /* Name.Constant */
.pygmentize_Pirvxn .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_Pirvxn .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_Pirvxn .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_Pirvxn .nf { color: #0000FF } /* Name.Function */
.pygmentize_Pirvxn .nl { color: #A0A000 } /* Name.Label */
.pygmentize_Pirvxn .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_Pirvxn .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_Pirvxn .nv { color: #19177C } /* Name.Variable */
.pygmentize_Pirvxn .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_Pirvxn .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_Pirvxn .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_Pirvxn .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_Pirvxn .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_Pirvxn .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_Pirvxn .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_Pirvxn .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_Pirvxn .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_Pirvxn .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_Pirvxn .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_Pirvxn .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_Pirvxn .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_Pirvxn .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_Pirvxn .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_Pirvxn .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_Pirvxn .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_Pirvxn .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_Pirvxn .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_Pirvxn .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_Pirvxn .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_Pirvxn .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_Pirvxn"><pre><span class="k">def</span> <span class="nf">first_triangle_with_divisors</span><span class="p">(</span><span class="n">num</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;</span>
<span class="sd">    Find the first triangle number with</span>
<span class="sd">    at least num number of divisors</span>
<span class="sd">    &#39;&#39;&#39;</span>
    <span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">triangle</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">factor_count</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">while</span> <span class="n">factor_count</span> <span class="o">&lt;</span> <span class="n">num</span><span class="p">:</span>
        <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">triangle</span> <span class="o">+=</span> <span class="n">count</span>
        <span class="n">factor_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">factors</span><span class="p">(</span><span class="n">triangle</span><span class="p">))</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">triangle</span><span class="p">,</span> <span class="n">factor_count</span><span class="p">)</span>
</pre></div>

</p>
<p>Walking through it, we start with<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_V8o1Uv  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_V8o1Uv .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_V8o1Uvtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_V8o1Uvtable td, .pygmentize_V8o1Uvtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_V8o1Uv pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_V8o1Uv {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_V8o1Uv {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_V8o1Uv td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_V8o1Uv .hll { background-color: #ffffcc }
.pygmentize_V8o1Uv  { background: #f8f8f8; }
.pygmentize_V8o1Uv .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_V8o1Uv .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_V8o1Uv .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_V8o1Uv .o { color: #666666 } /* Operator */
.pygmentize_V8o1Uv .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_V8o1Uv .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_V8o1Uv .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_V8o1Uv .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_V8o1Uv .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_V8o1Uv .ge { font-style: italic } /* Generic.Emph */
.pygmentize_V8o1Uv .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_V8o1Uv .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_V8o1Uv .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_V8o1Uv .go { color: #808080 } /* Generic.Output */
.pygmentize_V8o1Uv .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_V8o1Uv .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_V8o1Uv .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_V8o1Uv .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_V8o1Uv .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_V8o1Uv .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_V8o1Uv .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_V8o1Uv .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_V8o1Uv .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_V8o1Uv .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_V8o1Uv .m { color: #666666 } /* Literal.Number */
.pygmentize_V8o1Uv .s { color: #BA2121 } /* Literal.String */
.pygmentize_V8o1Uv .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_V8o1Uv .nb { color: #008000 } /* Name.Builtin */
.pygmentize_V8o1Uv .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_V8o1Uv .no { color: #880000 } /* Name.Constant */
.pygmentize_V8o1Uv .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_V8o1Uv .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_V8o1Uv .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_V8o1Uv .nf { color: #0000FF } /* Name.Function */
.pygmentize_V8o1Uv .nl { color: #A0A000 } /* Name.Label */
.pygmentize_V8o1Uv .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_V8o1Uv .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_V8o1Uv .nv { color: #19177C } /* Name.Variable */
.pygmentize_V8o1Uv .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_V8o1Uv .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_V8o1Uv .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_V8o1Uv .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_V8o1Uv .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_V8o1Uv .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_V8o1Uv .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_V8o1Uv .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_V8o1Uv .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_V8o1Uv .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_V8o1Uv .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_V8o1Uv .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_V8o1Uv .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_V8o1Uv .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_V8o1Uv .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_V8o1Uv .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_V8o1Uv .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_V8o1Uv .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_V8o1Uv .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_V8o1Uv .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_V8o1Uv .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_V8o1Uv .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_V8o1Uv"><pre><span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
</pre></div>

<br />
so we can determine the next number that has to be added&#8211;it allows us to make the triangle number sequence. We set<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_J3r8yE  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_J3r8yE .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_J3r8yEtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_J3r8yEtable td, .pygmentize_J3r8yEtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_J3r8yE pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_J3r8yE {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_J3r8yE {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_J3r8yE td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_J3r8yE .hll { background-color: #ffffcc }
.pygmentize_J3r8yE  { background: #f8f8f8; }
.pygmentize_J3r8yE .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_J3r8yE .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_J3r8yE .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_J3r8yE .o { color: #666666 } /* Operator */
.pygmentize_J3r8yE .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_J3r8yE .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_J3r8yE .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_J3r8yE .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_J3r8yE .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_J3r8yE .ge { font-style: italic } /* Generic.Emph */
.pygmentize_J3r8yE .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_J3r8yE .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_J3r8yE .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_J3r8yE .go { color: #808080 } /* Generic.Output */
.pygmentize_J3r8yE .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_J3r8yE .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_J3r8yE .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_J3r8yE .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_J3r8yE .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_J3r8yE .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_J3r8yE .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_J3r8yE .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_J3r8yE .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_J3r8yE .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_J3r8yE .m { color: #666666 } /* Literal.Number */
.pygmentize_J3r8yE .s { color: #BA2121 } /* Literal.String */
.pygmentize_J3r8yE .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_J3r8yE .nb { color: #008000 } /* Name.Builtin */
.pygmentize_J3r8yE .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_J3r8yE .no { color: #880000 } /* Name.Constant */
.pygmentize_J3r8yE .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_J3r8yE .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_J3r8yE .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_J3r8yE .nf { color: #0000FF } /* Name.Function */
.pygmentize_J3r8yE .nl { color: #A0A000 } /* Name.Label */
.pygmentize_J3r8yE .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_J3r8yE .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_J3r8yE .nv { color: #19177C } /* Name.Variable */
.pygmentize_J3r8yE .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_J3r8yE .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_J3r8yE .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_J3r8yE .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_J3r8yE .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_J3r8yE .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_J3r8yE .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_J3r8yE .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_J3r8yE .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_J3r8yE .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_J3r8yE .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_J3r8yE .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_J3r8yE .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_J3r8yE .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_J3r8yE .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_J3r8yE .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_J3r8yE .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_J3r8yE .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_J3r8yE .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_J3r8yE .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_J3r8yE .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_J3r8yE .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_J3r8yE"><pre><span class="n">triangle</span> <span class="o">=</span> <span class="mi">1</span>
</pre></div>

<br />
&#8230;our first triangle number. And then we set up a spot for the factor_count, so that we can set up a while loop with it.</p>
<p>The loop will iterate until<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_DLiMtN  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_DLiMtN .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_DLiMtNtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_DLiMtNtable td, .pygmentize_DLiMtNtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_DLiMtN pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_DLiMtN {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_DLiMtN {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_DLiMtN td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_DLiMtN .hll { background-color: #ffffcc }
.pygmentize_DLiMtN  { background: #f8f8f8; }
.pygmentize_DLiMtN .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_DLiMtN .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_DLiMtN .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_DLiMtN .o { color: #666666 } /* Operator */
.pygmentize_DLiMtN .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_DLiMtN .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_DLiMtN .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_DLiMtN .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_DLiMtN .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_DLiMtN .ge { font-style: italic } /* Generic.Emph */
.pygmentize_DLiMtN .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_DLiMtN .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_DLiMtN .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_DLiMtN .go { color: #808080 } /* Generic.Output */
.pygmentize_DLiMtN .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_DLiMtN .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_DLiMtN .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_DLiMtN .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_DLiMtN .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_DLiMtN .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_DLiMtN .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_DLiMtN .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_DLiMtN .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_DLiMtN .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_DLiMtN .m { color: #666666 } /* Literal.Number */
.pygmentize_DLiMtN .s { color: #BA2121 } /* Literal.String */
.pygmentize_DLiMtN .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_DLiMtN .nb { color: #008000 } /* Name.Builtin */
.pygmentize_DLiMtN .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_DLiMtN .no { color: #880000 } /* Name.Constant */
.pygmentize_DLiMtN .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_DLiMtN .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_DLiMtN .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_DLiMtN .nf { color: #0000FF } /* Name.Function */
.pygmentize_DLiMtN .nl { color: #A0A000 } /* Name.Label */
.pygmentize_DLiMtN .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_DLiMtN .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_DLiMtN .nv { color: #19177C } /* Name.Variable */
.pygmentize_DLiMtN .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_DLiMtN .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_DLiMtN .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_DLiMtN .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_DLiMtN .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_DLiMtN .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_DLiMtN .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_DLiMtN .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_DLiMtN .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_DLiMtN .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_DLiMtN .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_DLiMtN .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_DLiMtN .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_DLiMtN .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_DLiMtN .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_DLiMtN .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_DLiMtN .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_DLiMtN .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_DLiMtN .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_DLiMtN .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_DLiMtN .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_DLiMtN .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_DLiMtN"><pre><span class="n">factor_count</span> <span class="o">&gt;</span> <span class="n">num</span>
</pre></div>

<br />
&#8230;with num being an argument the function accepts. We could hard-code this to 500, but I set it as a variable so that I can run the known case (28 is the first number with > 5 factors) to verify working code.</p>
<p>This code fails in one case, if you input 1 for num. It&#8217;s trivial to fix, but doesn&#8217;t matter for our application. To fix it you would just insert, at the beginning of the function:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_4lb4EW  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_4lb4EW .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_4lb4EWtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_4lb4EWtable td, .pygmentize_4lb4EWtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_4lb4EW pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_4lb4EW {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_4lb4EW {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_4lb4EW td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_4lb4EW .hll { background-color: #ffffcc }
.pygmentize_4lb4EW  { background: #f8f8f8; }
.pygmentize_4lb4EW .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_4lb4EW .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_4lb4EW .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_4lb4EW .o { color: #666666 } /* Operator */
.pygmentize_4lb4EW .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_4lb4EW .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_4lb4EW .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_4lb4EW .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_4lb4EW .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_4lb4EW .ge { font-style: italic } /* Generic.Emph */
.pygmentize_4lb4EW .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_4lb4EW .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_4lb4EW .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_4lb4EW .go { color: #808080 } /* Generic.Output */
.pygmentize_4lb4EW .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_4lb4EW .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_4lb4EW .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_4lb4EW .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_4lb4EW .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_4lb4EW .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_4lb4EW .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_4lb4EW .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_4lb4EW .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_4lb4EW .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_4lb4EW .m { color: #666666 } /* Literal.Number */
.pygmentize_4lb4EW .s { color: #BA2121 } /* Literal.String */
.pygmentize_4lb4EW .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_4lb4EW .nb { color: #008000 } /* Name.Builtin */
.pygmentize_4lb4EW .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_4lb4EW .no { color: #880000 } /* Name.Constant */
.pygmentize_4lb4EW .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_4lb4EW .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_4lb4EW .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_4lb4EW .nf { color: #0000FF } /* Name.Function */
.pygmentize_4lb4EW .nl { color: #A0A000 } /* Name.Label */
.pygmentize_4lb4EW .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_4lb4EW .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_4lb4EW .nv { color: #19177C } /* Name.Variable */
.pygmentize_4lb4EW .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_4lb4EW .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_4lb4EW .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_4lb4EW .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_4lb4EW .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_4lb4EW .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_4lb4EW .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_4lb4EW .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_4lb4EW .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_4lb4EW .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_4lb4EW .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_4lb4EW .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_4lb4EW .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_4lb4EW .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_4lb4EW .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_4lb4EW .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_4lb4EW .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_4lb4EW .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_4lb4EW .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_4lb4EW .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_4lb4EW .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_4lb4EW .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_4lb4EW"><pre><span class="k">if</span> <span class="n">num</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
  <span class="k">return</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>

</p>
<p>During each loop, we increase our count, and then add it to the previous triangle number to get the new one. Then we call our factors() function on the new number, which returns a list of factors. We count them with len() and only finish if they&#8217;re over our target.</p>
<p>The end of my file just has a couple of cases:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_HHCi75  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_HHCi75 .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_HHCi75table {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_HHCi75table td, .pygmentize_HHCi75table th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_HHCi75 pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_HHCi75 {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_HHCi75 {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_HHCi75 td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_HHCi75 .hll { background-color: #ffffcc }
.pygmentize_HHCi75  { background: #f8f8f8; }
.pygmentize_HHCi75 .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_HHCi75 .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_HHCi75 .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_HHCi75 .o { color: #666666 } /* Operator */
.pygmentize_HHCi75 .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_HHCi75 .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_HHCi75 .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_HHCi75 .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_HHCi75 .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_HHCi75 .ge { font-style: italic } /* Generic.Emph */
.pygmentize_HHCi75 .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_HHCi75 .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_HHCi75 .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_HHCi75 .go { color: #808080 } /* Generic.Output */
.pygmentize_HHCi75 .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_HHCi75 .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_HHCi75 .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_HHCi75 .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_HHCi75 .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_HHCi75 .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_HHCi75 .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_HHCi75 .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_HHCi75 .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_HHCi75 .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_HHCi75 .m { color: #666666 } /* Literal.Number */
.pygmentize_HHCi75 .s { color: #BA2121 } /* Literal.String */
.pygmentize_HHCi75 .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_HHCi75 .nb { color: #008000 } /* Name.Builtin */
.pygmentize_HHCi75 .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_HHCi75 .no { color: #880000 } /* Name.Constant */
.pygmentize_HHCi75 .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_HHCi75 .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_HHCi75 .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_HHCi75 .nf { color: #0000FF } /* Name.Function */
.pygmentize_HHCi75 .nl { color: #A0A000 } /* Name.Label */
.pygmentize_HHCi75 .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_HHCi75 .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_HHCi75 .nv { color: #19177C } /* Name.Variable */
.pygmentize_HHCi75 .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_HHCi75 .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_HHCi75 .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_HHCi75 .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_HHCi75 .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_HHCi75 .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_HHCi75 .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_HHCi75 .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_HHCi75 .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_HHCi75 .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_HHCi75 .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_HHCi75 .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_HHCi75 .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_HHCi75 .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_HHCi75 .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_HHCi75 .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_HHCi75 .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_HHCi75 .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_HHCi75 .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_HHCi75 .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_HHCi75 .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_HHCi75 .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_HHCi75"><pre><span class="k">print</span> <span class="n">first_triangle_with_divisors</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">print</span> <span class="n">first_triangle_with_divisors</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span>
<span class="k">print</span> <span class="n">first_triangle_with_divisors</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>
</pre></div>

</p>
<p>And returns the correct answer.</p>
<p>We can speed the function for large numbers. It&#8217;s hard to be perfect, and probably harder to prove mathematically, but it makes a lot of sense that the first number with 500 divisors is probably divisible by both 2 and 3, and possibly 5 which will give it a lot of &#8220;extra&#8221; divisors.</p>
<p>On my machine this runs in about 10 seconds, and it&#8217;s cut fairly drastically by including an extra line:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_JN2bQf  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_JN2bQf .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_JN2bQftable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_JN2bQftable td, .pygmentize_JN2bQftable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_JN2bQf pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_JN2bQf {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_JN2bQf {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_JN2bQf td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_JN2bQf .hll { background-color: #ffffcc }
.pygmentize_JN2bQf  { background: #f8f8f8; }
.pygmentize_JN2bQf .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_JN2bQf .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_JN2bQf .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_JN2bQf .o { color: #666666 } /* Operator */
.pygmentize_JN2bQf .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_JN2bQf .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_JN2bQf .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_JN2bQf .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_JN2bQf .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_JN2bQf .ge { font-style: italic } /* Generic.Emph */
.pygmentize_JN2bQf .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_JN2bQf .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_JN2bQf .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_JN2bQf .go { color: #808080 } /* Generic.Output */
.pygmentize_JN2bQf .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_JN2bQf .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_JN2bQf .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_JN2bQf .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_JN2bQf .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_JN2bQf .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_JN2bQf .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_JN2bQf .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_JN2bQf .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_JN2bQf .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_JN2bQf .m { color: #666666 } /* Literal.Number */
.pygmentize_JN2bQf .s { color: #BA2121 } /* Literal.String */
.pygmentize_JN2bQf .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_JN2bQf .nb { color: #008000 } /* Name.Builtin */
.pygmentize_JN2bQf .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_JN2bQf .no { color: #880000 } /* Name.Constant */
.pygmentize_JN2bQf .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_JN2bQf .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_JN2bQf .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_JN2bQf .nf { color: #0000FF } /* Name.Function */
.pygmentize_JN2bQf .nl { color: #A0A000 } /* Name.Label */
.pygmentize_JN2bQf .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_JN2bQf .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_JN2bQf .nv { color: #19177C } /* Name.Variable */
.pygmentize_JN2bQf .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_JN2bQf .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_JN2bQf .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_JN2bQf .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_JN2bQf .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_JN2bQf .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_JN2bQf .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_JN2bQf .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_JN2bQf .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_JN2bQf .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_JN2bQf .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_JN2bQf .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_JN2bQf .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_JN2bQf .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_JN2bQf .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_JN2bQf .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_JN2bQf .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_JN2bQf .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_JN2bQf .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_JN2bQf .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_JN2bQf .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_JN2bQf .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_JN2bQf"><pre><span class="k">while</span> <span class="n">factor_count</span> <span class="o">&lt;</span> <span class="n">num</span><span class="p">:</span>
        <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">triangle</span> <span class="o">+=</span> <span class="n">count</span>
        <span class="k">if</span> <span class="n">num</span> <span class="o">&lt;</span> <span class="mi">100</span> <span class="ow">or</span> <span class="n">num</span> <span class="o">&gt;</span> <span class="mi">100</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">triangle</span> <span class="o">%</span> <span class="mi">2</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">triangle</span> <span class="o">%</span> <span class="mi">3</span><span class="p">:</span>
            <span class="n">factor_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">factors</span><span class="p">(</span><span class="n">triangle</span><span class="p">))</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">triangle</span><span class="p">,</span> <span class="n">factor_count</span><span class="p">)</span>
</pre></div>

</p>
<p>This simply means we&#8217;ll skip our most time-sinking function, factors(), if we need a high number of factors and the triangle is not evenly divisible by 2 and 3. This ONLY works if you need the FIRST number that qualifies, because you will eventually run into a number, I think, with 500+ divisors that is not evenly divisible by 2 or 3.</p>
<p>Of note:<br />
Do some research on whitespace. I had an invisible error, to the naked eye, that cost me an hour of frustrating debugging&#8211;my factor function was exiting early and I couldn&#8217;t figure out why. Some weird whitespace accident with Vim, my editor of choice.</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/project-euler-problem-12-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>March 2012 Pool Winnings</title>
		<link>http://jessebriggs.net/march-2012-pool-winnings/</link>
		<comments>http://jessebriggs.net/march-2012-pool-winnings/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 10:37:28 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=186</guid>
		<description><![CDATA[Total: +$280 03/16/2012: $5 entry singles at 3Bs. $5 sidebet with J.O. in finals. +$100 03/07/2012: Chopped free tourney with Gary Plymale, even though I would have to beat him twice. +$70 03/03/2012: Played 2 $50 sets with J.O. Went 1-1 03/03/2012: Bet $10 on the side with J.O. during tourney. 03/03/2012: Won the free [...]]]></description>
			<content:encoded><![CDATA[<h3>Total: +$280</h3>
<p>03/16/2012: $5 entry singles at 3Bs. $5 sidebet with J.O. in finals. +$100<br />
03/07/2012: Chopped free tourney with Gary Plymale, even though I would have to beat him twice. +$70<br />
03/03/2012: Played 2 $50 sets with J.O. Went 1-1<br />
03/03/2012: Bet $10 on the side with J.O. during tourney.<br />
03/03/2012: Won the free tourney. Never lost a game. +$100</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/march-2012-pool-winnings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 10 in Python</title>
		<link>http://jessebriggs.net/project-euler-problem-10-in-python/</link>
		<comments>http://jessebriggs.net/project-euler-problem-10-in-python/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 01:07:43 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=179</guid>
		<description><![CDATA[Project Euler Problem 10 reads: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. This is really a cinch. We already have established a sieve generator for prime numbers in Project Euler Problem 3 in Python, and [...]]]></description>
			<content:encoded><![CDATA[<p>Project Euler Problem 10 reads:</p>
<blockquote><p>The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.</p>
<p>Find the sum of all the primes below two million.</p></blockquote>
<p>This is really a cinch. We already have established a sieve generator for prime numbers in <a href="project-euler-problem-3/">Project Euler Problem 3 in Python</a>, and hopefully by now you&#8217;ve done the helper &#8220;homework&#8221; function to map the grid to a list. So we just run it for 2,000,000 and then sum them. The built-in <style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_kd4iRp  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_kd4iRp .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_kd4iRptable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_kd4iRptable td, .pygmentize_kd4iRptable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_kd4iRp pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_kd4iRp {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_kd4iRp {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_kd4iRp td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_kd4iRp .hll { background-color: #ffffcc }
.pygmentize_kd4iRp  { background: #f8f8f8; }
.pygmentize_kd4iRp .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_kd4iRp .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_kd4iRp .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_kd4iRp .o { color: #666666 } /* Operator */
.pygmentize_kd4iRp .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_kd4iRp .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_kd4iRp .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_kd4iRp .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_kd4iRp .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_kd4iRp .ge { font-style: italic } /* Generic.Emph */
.pygmentize_kd4iRp .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_kd4iRp .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_kd4iRp .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_kd4iRp .go { color: #808080 } /* Generic.Output */
.pygmentize_kd4iRp .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_kd4iRp .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_kd4iRp .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_kd4iRp .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_kd4iRp .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_kd4iRp .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_kd4iRp .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_kd4iRp .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_kd4iRp .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_kd4iRp .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_kd4iRp .m { color: #666666 } /* Literal.Number */
.pygmentize_kd4iRp .s { color: #BA2121 } /* Literal.String */
.pygmentize_kd4iRp .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_kd4iRp .nb { color: #008000 } /* Name.Builtin */
.pygmentize_kd4iRp .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_kd4iRp .no { color: #880000 } /* Name.Constant */
.pygmentize_kd4iRp .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_kd4iRp .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_kd4iRp .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_kd4iRp .nf { color: #0000FF } /* Name.Function */
.pygmentize_kd4iRp .nl { color: #A0A000 } /* Name.Label */
.pygmentize_kd4iRp .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_kd4iRp .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_kd4iRp .nv { color: #19177C } /* Name.Variable */
.pygmentize_kd4iRp .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_kd4iRp .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_kd4iRp .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_kd4iRp .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_kd4iRp .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_kd4iRp .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_kd4iRp .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_kd4iRp .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_kd4iRp .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_kd4iRp .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_kd4iRp .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_kd4iRp .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_kd4iRp .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_kd4iRp .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_kd4iRp .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_kd4iRp .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_kd4iRp .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_kd4iRp .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_kd4iRp .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_kd4iRp .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_kd4iRp .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_kd4iRp .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_kd4iRp"><pre><span class="nb">sum</span><span class="p">()</span>
</pre></div>

 sums a list. So a one-liner, using your own function name for the helper:</p>
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_Qjra9z  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_Qjra9z .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_Qjra9ztable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_Qjra9ztable td, .pygmentize_Qjra9ztable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_Qjra9z pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_Qjra9z {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_Qjra9z {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_Qjra9z td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_Qjra9z .hll { background-color: #ffffcc }
.pygmentize_Qjra9z  { background: #f8f8f8; }
.pygmentize_Qjra9z .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_Qjra9z .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_Qjra9z .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_Qjra9z .o { color: #666666 } /* Operator */
.pygmentize_Qjra9z .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_Qjra9z .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_Qjra9z .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_Qjra9z .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_Qjra9z .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_Qjra9z .ge { font-style: italic } /* Generic.Emph */
.pygmentize_Qjra9z .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_Qjra9z .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_Qjra9z .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_Qjra9z .go { color: #808080 } /* Generic.Output */
.pygmentize_Qjra9z .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_Qjra9z .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_Qjra9z .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_Qjra9z .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_Qjra9z .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_Qjra9z .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_Qjra9z .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_Qjra9z .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_Qjra9z .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_Qjra9z .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_Qjra9z .m { color: #666666 } /* Literal.Number */
.pygmentize_Qjra9z .s { color: #BA2121 } /* Literal.String */
.pygmentize_Qjra9z .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_Qjra9z .nb { color: #008000 } /* Name.Builtin */
.pygmentize_Qjra9z .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_Qjra9z .no { color: #880000 } /* Name.Constant */
.pygmentize_Qjra9z .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_Qjra9z .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_Qjra9z .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_Qjra9z .nf { color: #0000FF } /* Name.Function */
.pygmentize_Qjra9z .nl { color: #A0A000 } /* Name.Label */
.pygmentize_Qjra9z .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_Qjra9z .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_Qjra9z .nv { color: #19177C } /* Name.Variable */
.pygmentize_Qjra9z .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_Qjra9z .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_Qjra9z .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_Qjra9z .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_Qjra9z .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_Qjra9z .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_Qjra9z .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_Qjra9z .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_Qjra9z .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_Qjra9z .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_Qjra9z .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_Qjra9z .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_Qjra9z .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_Qjra9z .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_Qjra9z .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_Qjra9z .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_Qjra9z .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_Qjra9z .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_Qjra9z .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_Qjra9z .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_Qjra9z .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_Qjra9z .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_Qjra9z"><pre><span class="k">print</span> <span class="nb">sum</span><span class="p">(</span><span class="n">prime_list_numbers</span><span class="p">[</span><span class="mi">2000000</span><span class="p">])</span>
</pre></div>


]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/project-euler-problem-10-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 9 in Python</title>
		<link>http://jessebriggs.net/project-euler-problem-9-in-python/</link>
		<comments>http://jessebriggs.net/project-euler-problem-9-in-python/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 22:03:33 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=176</guid>
		<description><![CDATA[Project Euler Problem 9 reads: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. [...]]]></description>
			<content:encoded><![CDATA[<p>Project Euler Problem 9 reads:</p>
<blockquote><p>
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,</p>
<p>a2 + b2 = c2<br />
For example, 32 + 42 = 9 + 16 = 25 = 52.</p>
<p>There exists exactly one Pythagorean triplet for which a + b + c = 1000.<br />
Find the product abc.
</p></blockquote>
<p>Natural meaning &#8220;whole&#8221; or integer.</p>
<p>Well we start out with nested ranges:</p>
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_K31rIK  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_K31rIK .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_K31rIKtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_K31rIKtable td, .pygmentize_K31rIKtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_K31rIK pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_K31rIK {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_K31rIK {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_K31rIK td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_K31rIK .hll { background-color: #ffffcc }
.pygmentize_K31rIK  { background: #f8f8f8; }
.pygmentize_K31rIK .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_K31rIK .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_K31rIK .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_K31rIK .o { color: #666666 } /* Operator */
.pygmentize_K31rIK .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_K31rIK .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_K31rIK .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_K31rIK .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_K31rIK .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_K31rIK .ge { font-style: italic } /* Generic.Emph */
.pygmentize_K31rIK .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_K31rIK .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_K31rIK .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_K31rIK .go { color: #808080 } /* Generic.Output */
.pygmentize_K31rIK .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_K31rIK .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_K31rIK .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_K31rIK .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_K31rIK .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_K31rIK .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_K31rIK .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_K31rIK .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_K31rIK .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_K31rIK .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_K31rIK .m { color: #666666 } /* Literal.Number */
.pygmentize_K31rIK .s { color: #BA2121 } /* Literal.String */
.pygmentize_K31rIK .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_K31rIK .nb { color: #008000 } /* Name.Builtin */
.pygmentize_K31rIK .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_K31rIK .no { color: #880000 } /* Name.Constant */
.pygmentize_K31rIK .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_K31rIK .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_K31rIK .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_K31rIK .nf { color: #0000FF } /* Name.Function */
.pygmentize_K31rIK .nl { color: #A0A000 } /* Name.Label */
.pygmentize_K31rIK .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_K31rIK .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_K31rIK .nv { color: #19177C } /* Name.Variable */
.pygmentize_K31rIK .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_K31rIK .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_K31rIK .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_K31rIK .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_K31rIK .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_K31rIK .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_K31rIK .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_K31rIK .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_K31rIK .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_K31rIK .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_K31rIK .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_K31rIK .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_K31rIK .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_K31rIK .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_K31rIK .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_K31rIK .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_K31rIK .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_K31rIK .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_K31rIK .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_K31rIK .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_K31rIK .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_K31rIK .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_K31rIK"><pre><span class="kn">import</span> <span class="nn">math</span>

<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">500</span><span class="p">):</span>
  <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">500</span><span class="p">):</span>
    <span class="n">c</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">a</span> <span class="o">*</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span> <span class="o">*</span> <span class="n">b</span><span class="p">)</span>
</pre></div>


<p>This looks like a good candidate for list comprehensions, and I tried them, but it gets a little messy. I really think this is a lot more legible. And with such a small range, we&#8217;re really not worried about this taking too terribly wrong as all the functions are math and comparisons (FAST).</p>
<p>So, to continue:<br />
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_XUsmyV  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_XUsmyV .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_XUsmyVtable {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_XUsmyVtable td, .pygmentize_XUsmyVtable th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_XUsmyV pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_XUsmyV {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_XUsmyV {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_XUsmyV td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_XUsmyV .hll { background-color: #ffffcc }
.pygmentize_XUsmyV  { background: #f8f8f8; }
.pygmentize_XUsmyV .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_XUsmyV .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_XUsmyV .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_XUsmyV .o { color: #666666 } /* Operator */
.pygmentize_XUsmyV .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_XUsmyV .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_XUsmyV .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_XUsmyV .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_XUsmyV .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_XUsmyV .ge { font-style: italic } /* Generic.Emph */
.pygmentize_XUsmyV .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_XUsmyV .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_XUsmyV .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_XUsmyV .go { color: #808080 } /* Generic.Output */
.pygmentize_XUsmyV .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_XUsmyV .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_XUsmyV .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_XUsmyV .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_XUsmyV .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_XUsmyV .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_XUsmyV .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_XUsmyV .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_XUsmyV .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_XUsmyV .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_XUsmyV .m { color: #666666 } /* Literal.Number */
.pygmentize_XUsmyV .s { color: #BA2121 } /* Literal.String */
.pygmentize_XUsmyV .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_XUsmyV .nb { color: #008000 } /* Name.Builtin */
.pygmentize_XUsmyV .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_XUsmyV .no { color: #880000 } /* Name.Constant */
.pygmentize_XUsmyV .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_XUsmyV .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_XUsmyV .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_XUsmyV .nf { color: #0000FF } /* Name.Function */
.pygmentize_XUsmyV .nl { color: #A0A000 } /* Name.Label */
.pygmentize_XUsmyV .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_XUsmyV .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_XUsmyV .nv { color: #19177C } /* Name.Variable */
.pygmentize_XUsmyV .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_XUsmyV .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_XUsmyV .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_XUsmyV .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_XUsmyV .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_XUsmyV .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_XUsmyV .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_XUsmyV .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_XUsmyV .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_XUsmyV .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_XUsmyV .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_XUsmyV .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_XUsmyV .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_XUsmyV .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_XUsmyV .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_XUsmyV .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_XUsmyV .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_XUsmyV .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_XUsmyV .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_XUsmyV .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_XUsmyV .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_XUsmyV .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_XUsmyV"><pre>    <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span> <span class="o">%</span> <span class="mi">1</span><span class="p">:</span> <span class="c">#making sure we have a natural number</span>
      <span class="k">if</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span> <span class="o">+</span> <span class="n">c</span> <span class="o">==</span> <span class="mi">1000</span><span class="p">:</span>
        <span class="k">print</span> <span class="nb">int</span><span class="p">(</span><span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span><span class="p">)</span>
</pre></div>

</p>
<p>Not too bad!</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/project-euler-problem-9-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 8 in Python</title>
		<link>http://jessebriggs.net/project-euler-problem-8-in-python/</link>
		<comments>http://jessebriggs.net/project-euler-problem-8-in-python/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 21:44:23 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jessebriggs.net/?p=173</guid>
		<description><![CDATA[Project Euler Problem 8: Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 So we&#8217;ll enter the number, take every 5-character section and find the product. So record is our place-holder for [...]]]></description>
			<content:encoded><![CDATA[<p>Project Euler Problem 8:</p>
<blockquote><p>
Find the greatest product of five consecutive digits in the 1000-digit number.</p>
<p>73167176531330624919225119674426574742355349194934<br />
96983520312774506326239578318016984801869478851843<br />
85861560789112949495459501737958331952853208805511<br />
12540698747158523863050715693290963295227443043557<br />
66896648950445244523161731856403098711121722383113<br />
62229893423380308135336276614282806444486645238749<br />
30358907296290491560440772390713810515859307960866<br />
70172427121883998797908792274921901699720888093776<br />
65727333001053367881220235421809751254540594752243<br />
52584907711670556013604839586446706324415722155397<br />
53697817977846174064955149290862569321978468622482<br />
83972241375657056057490261407972968652414535100474<br />
82166370484403199890008895243450658541227588666881<br />
16427171479924442928230863465674813919123162824586<br />
17866458359124566529476545682848912883142607690042<br />
24219022671055626321111109370544217506941658960408<br />
07198403850962455444362981230987879927244284909188<br />
84580156166097919133875499200524063689912560717606<br />
05886116467109405077541002256983155200055935729725<br />
71636269561882670428252483600823257530420752963450
</p></blockquote>
<p>So we&#8217;ll enter the number, take every 5-character section and find the product.</p>
<style type="text/css">


/* *************************************************** */
/* WordPress default theme "twenty-ten" compatibility: */
/* FIXME: Is there a way to limit these changes to pygmentize_DzyoG6  */
/*        without editing the WordPress theme directly? */
/* *************************************************** */

#content pre {
  /* The background: transparent is needed to work with WordPress:*/
  background: transparent;
  /* Default WordPress style has a big fat <pre> margin-bottom: */
  margin-bottom: 0px;

  /*color: #333333;*/
  font-size: .9em; 
  line-height: 1.25em;
}

#content table {
}

#content table {
	border: 1px solid #e7e7e7;
    margin: 0 0 0 0;
	text-align: left;
	width: 100%;
}
#content tr th,
#content thead th {
	color: #888;
	font-size: 12px;
	font-weight: bold;
	line-height: 18px;
	padding: 0px;
}
#content tr td {
	border: 0px;
	padding: 0px;
	margin: 0px;
    margin-bottom: 0px;
    padding-bottom: 0px;

}

/* *************************************************** */
/* *************************************************** */

/* Standard fixes to the default output: */

/* Set the tab width in "ch" character units: */
.pygmentize_DzyoG6 .tabspan {
  display: inline-block;
  width: 4ch;
}

/* When using line numbers, use 100% table width and no cellpadding: */
.pygmentize_DzyoG6table {
  width: 100%;
  border-spacing: 0px;
  border-collapse: collapse;
}


/*
#content table {
    border: 1px solid #E7E7E7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
*/

.pygmentize_DzyoG6table td, .pygmentize_DzyoG6table th {
  padding: 0px;
  margin: 0px;
}

/* Add a little buffer so the monotype font doesn't bump directly against the edge: */
.pygmentize_DzyoG6 pre {
  padding: .6ch;
  
}

/* This is more consistent with <p> tags... I didn't like it for my use: */
/*
div .pygmentize_DzyoG6 {
    margin-bottom: 24px; 
}
*/

td.linenos.pygmentize_DzyoG6 {
  width: 1ch;
  padding: .6ch;
  line-height: 1.25em;
}

.pygmentize_DzyoG6 td {
  padding-right: 1px;
}


td.linenos { background-color: #f0f0f0; padding-right: 1px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
.pygmentize_DzyoG6 .hll { background-color: #ffffcc }
.pygmentize_DzyoG6  { background: #f8f8f8; }
.pygmentize_DzyoG6 .c { color: #408080; font-style: italic } /* Comment */
.pygmentize_DzyoG6 .err { border: 1px solid #FF0000 } /* Error */
.pygmentize_DzyoG6 .k { color: #008000; font-weight: bold } /* Keyword */
.pygmentize_DzyoG6 .o { color: #666666 } /* Operator */
.pygmentize_DzyoG6 .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.pygmentize_DzyoG6 .cp { color: #BC7A00 } /* Comment.Preproc */
.pygmentize_DzyoG6 .c1 { color: #408080; font-style: italic } /* Comment.Single */
.pygmentize_DzyoG6 .cs { color: #408080; font-style: italic } /* Comment.Special */
.pygmentize_DzyoG6 .gd { color: #A00000 } /* Generic.Deleted */
.pygmentize_DzyoG6 .ge { font-style: italic } /* Generic.Emph */
.pygmentize_DzyoG6 .gr { color: #FF0000 } /* Generic.Error */
.pygmentize_DzyoG6 .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.pygmentize_DzyoG6 .gi { color: #00A000 } /* Generic.Inserted */
.pygmentize_DzyoG6 .go { color: #808080 } /* Generic.Output */
.pygmentize_DzyoG6 .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.pygmentize_DzyoG6 .gs { font-weight: bold } /* Generic.Strong */
.pygmentize_DzyoG6 .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.pygmentize_DzyoG6 .gt { color: #0040D0 } /* Generic.Traceback */
.pygmentize_DzyoG6 .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.pygmentize_DzyoG6 .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.pygmentize_DzyoG6 .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.pygmentize_DzyoG6 .kp { color: #008000 } /* Keyword.Pseudo */
.pygmentize_DzyoG6 .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.pygmentize_DzyoG6 .kt { color: #B00040 } /* Keyword.Type */
.pygmentize_DzyoG6 .m { color: #666666 } /* Literal.Number */
.pygmentize_DzyoG6 .s { color: #BA2121 } /* Literal.String */
.pygmentize_DzyoG6 .na { color: #7D9029 } /* Name.Attribute */
.pygmentize_DzyoG6 .nb { color: #008000 } /* Name.Builtin */
.pygmentize_DzyoG6 .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.pygmentize_DzyoG6 .no { color: #880000 } /* Name.Constant */
.pygmentize_DzyoG6 .nd { color: #AA22FF } /* Name.Decorator */
.pygmentize_DzyoG6 .ni { color: #999999; font-weight: bold } /* Name.Entity */
.pygmentize_DzyoG6 .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.pygmentize_DzyoG6 .nf { color: #0000FF } /* Name.Function */
.pygmentize_DzyoG6 .nl { color: #A0A000 } /* Name.Label */
.pygmentize_DzyoG6 .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.pygmentize_DzyoG6 .nt { color: #008000; font-weight: bold } /* Name.Tag */
.pygmentize_DzyoG6 .nv { color: #19177C } /* Name.Variable */
.pygmentize_DzyoG6 .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.pygmentize_DzyoG6 .w { color: #bbbbbb } /* Text.Whitespace */
.pygmentize_DzyoG6 .mf { color: #666666 } /* Literal.Number.Float */
.pygmentize_DzyoG6 .mh { color: #666666 } /* Literal.Number.Hex */
.pygmentize_DzyoG6 .mi { color: #666666 } /* Literal.Number.Integer */
.pygmentize_DzyoG6 .mo { color: #666666 } /* Literal.Number.Oct */
.pygmentize_DzyoG6 .sb { color: #BA2121 } /* Literal.String.Backtick */
.pygmentize_DzyoG6 .sc { color: #BA2121 } /* Literal.String.Char */
.pygmentize_DzyoG6 .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.pygmentize_DzyoG6 .s2 { color: #BA2121 } /* Literal.String.Double */
.pygmentize_DzyoG6 .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.pygmentize_DzyoG6 .sh { color: #BA2121 } /* Literal.String.Heredoc */
.pygmentize_DzyoG6 .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.pygmentize_DzyoG6 .sx { color: #008000 } /* Literal.String.Other */
.pygmentize_DzyoG6 .sr { color: #BB6688 } /* Literal.String.Regex */
.pygmentize_DzyoG6 .s1 { color: #BA2121 } /* Literal.String.Single */
.pygmentize_DzyoG6 .ss { color: #19177C } /* Literal.String.Symbol */
.pygmentize_DzyoG6 .bp { color: #008000 } /* Name.Builtin.Pseudo */
.pygmentize_DzyoG6 .vc { color: #19177C } /* Name.Variable.Class */
.pygmentize_DzyoG6 .vg { color: #19177C } /* Name.Variable.Global */
.pygmentize_DzyoG6 .vi { color: #19177C } /* Name.Variable.Instance */
.pygmentize_DzyoG6 .il { color: #666666 } /* Literal.Number.Integer.Long */

  </style>




<div class="pygmentize_DzyoG6"><pre><span class="n">record</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">995</span><span class="p">):</span>
  <span class="n">total</span> <span class="o">=</span> <span class="mi">1</span>
  <span class="n">portion</span> <span class="o">=</span> <span class="n">number</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">i</span><span class="o">+</span><span class="mi">5</span><span class="p">]</span> <span class="c">#pull out the section</span>
  <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">):</span>
    <span class="n">total</span> <span class="o">*=</span> <span class="nb">int</span><span class="p">(</span><span class="n">portion</span><span class="p">[</span><span class="n">x</span><span class="p">])</span>
  <span class="k">if</span> <span class="n">total</span> <span class="o">&gt;</span> <span class="n">record</span><span class="p">:</span>
    <span class="n">record</span> <span class="o">=</span> <span class="n">total</span>
<span class="k">print</span> <span class="n">record</span>
</pre></div>


<p>So record is our place-holder for the record-setting number. We go 0-995 to find all the possible starting spots for 5-character-length strings. We find a product and compare to our previous record. I didn&#8217;t show setting the number, it&#8217;s set as &#8220;number&#8221; and I just didn&#8217;t want to repeat the 1,000 digits. Brute force FTW as usual.</p>
]]></content:encoded>
			<wfw:commentRss>http://jessebriggs.net/project-euler-problem-8-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

