I’ve been working on the Introduction to Computer Science from MIT’s OpenCourseWare.

Mashing through the homework is a double-struggle as I don’t really know Python but after about 2 hours I figured out the first problem of the first assignment:

`# Problem Set 1`

# Name: Ian Hall

# Collaborators: akonkol

# Time: too long

#

potential_primes = range(1,10000)

howmanyprimes = 0

for p in potential_primes:

dividesby = 0

divisors = range(1,p)

for d in divisors:

if p%d == 0 and p != d and d != 1:

dividesby = dividesby + 1

if dividesby == 0 and p != 1 and howmanyprimes < 1000:

howmanyprimes = howmanyprimes + 1

print(p,'is prime and',howmanyprimes,'of 1000 primes found.')

I’m pretty excited to get it working because it’s my first Python program, I’m not “MIT smart,” and I am not terribly adept at math.

*what we risk will be regained*

### Like this:

Like Loading...

*Related*