morayi


Joined 6 months 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 Set 1a
# Name: MORAYI
# Collaborators: Curious Reef: duallain
# Time: 2+ days
#

from math import log

primeCandidate = 3 
primeCounter = 1 
primes = [2]
logSum=0


primeLimit = int(raw_input('Please enter upper limit of primes: '))

def isprime(n):
	for x in primes:
		if n % x == 0:
			return False
	return True


while ( primeCounter < primeLimit ): 
	if isprime(primeCandidate) == True:
		primes.append(primeCandidate)
		primeCounter += 1
		primeCandidate += 2
	else:
		primeCandidate += 1

#####
# Problem Set 1b
# Name: MORAYI
# Collaborators: Curious Reef: duallain
# Time: 0:30 min

n = primes[-1]
for x in primes:
  if x <= n:
    logSum = logSum + log(x)

print primes
print "the sum of log(prime) where prime <= n = ", logSum      
print "n = ", n
print "The ratio of logSum/n = ", logSum/n

morayi 6 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1
# Problem Set 0 
# Name: MORAYI
# Collaborators: N/A 
# Time: 0:05 
#
userLastName = str(raw_input("Enter your last name: "))
userFirstName = str(raw_input("Enter your first name: "))
print (userFirstName)
print (userLastName)

morayi 6 months ago