[Greenbuilding] Pithy python

Kathy Cochran kathys_old_house at goldrush.com
Sat Jan 22 13:22:31 CST 2011


Does that mean that something either fabulous or catastrophic is going to
happen this year?  (But I confess, being a "numbers nurd", that is rather
interesting.)

Kathy

-----Original Message-----
From: greenbuilding-bounces at lists.bioenergylists.org
[mailto:greenbuilding-bounces at lists.bioenergylists.org] On Behalf Of nick
pine
Sent: Saturday, January 22, 2011 4:46 AM
To: greenbuilding at lists.bioenergylists.org
Subject: [Greenbuilding] Pithy python

Nathan Hurst writes:

>nick pine wrote:

>> 2011 is the sum of 11 consecutive primes.

python
>>> primes = [2]
>>> for i in range(2, 2011):
...   if all((i % x) for x in primes):
...     primes.append(i)
... 
>>> firstprime = bisect.bisect_left([sum(primes[i:i+11]) for i in
range(len(primes))], 2011)
>>> print firstprime
36
>>> sum( primes[36:36+11])
2011
>>> primes[36:36+11]
[157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211]

njh

_______________________________________________
Greenbuilding mailing list
to Send a Message to the list, use the email address
Greenbuilding at bioenergylists.org

to UNSUBSCRIBE or Change your List Settings use the web page
http://lists.bioenergylists.org/mailman/listinfo/greenbuilding_lists.bioener
gylists.org





More information about the Greenbuilding mailing list