m0nkeysensei


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
from math import *
def prime_counter():
    odd = 1
    max = 1
    l = log(2)
    n = raw_input('How many primes to count to?', )
    while max <= int(n):       #Sets up main loop
        odd += 2                 #incriments odd by 2 every new loop
        for x in range(2, odd):  #sets up loop with current odd value as range limit
            non_zero = (odd % x) #uses current position in range (x) as modulus value
            if non_zero is 0:    #if there is no remainder its not prime
                break           #go to next number in max range
            else:                #if there is a remainder
                continue           #go to next number in x range
        else:                     #if prime
            print odd           #print odd
            max += 1            #incriment main loop by 1
            l = l + log(odd)
    else:
        print 'max prime ' + str(odd)
        print l
        print (float(l)/float(n))

prime_counter()

m0nkeysensei 1 year ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1
def name_prompt():
    first = raw_input('Please Enter Your First Name: ')
    last = raw_input('Please Enter Your Last Name: ')
    
    return "%s %s" % (first, last)

whole_name = name_prompt()
print "Your name is %s" % whole_name

m0nkeysensei 1 year ago