andrewmeyer


Joined 1 year ago
Homeworks submitted:
Homework comments:
2
0

About Me

No description provided.

Classes

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 11% complete

Submitted Assignments

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1
# Problem 1

primes = [2] # The first of the Primes.
x = 3        # First number to test.


while len(primes) < 1000:   # Check that we still haven't found the 1000th prime!
    isprime = True    # Assume the number IS prime.  Test against it.
    for prime in primes: # For all the primes;
        if (x%prime) == 0: # check to see if the number is divisable by a prime.  If it is, set isprime to False.
            isprime = False
    if isprime:
        primes.append(x)   
    x = x+2
print "And the 1000th Prime is...  *drumroll*", primes[-1]

# Problem 2
print "And now for some Prime logging!"
from math import *

someLog = 0
n = input("So, what should our value of 'n' be?")

for prime in primes:
    if prime <= n:
        someLog = someLog + log(x)

print "Sum of the Prime logs: ", someLog
print "Wait, what was 'n' anyway? ", n
print "And how are they related now? ", someLog/n

andrewmeyer 1 year ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1
# Problem Set 0
# Name: Andrew
# Time: 0:04 
#
# Inputs users last name then first name and returns first name and last name in proper order

lastName = raw_input("What is your last name? ")
firstName = raw_input("What's your first name? ")

print firstName, lastName

andrewmeyer 1 year ago