jaioxung


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

This was a sizable jump from the first assignment.

# Problem Set 1
# Name: Jaioxung
# Collaborators: none
# Time: ?
#

## PROBLEM 1 ##

n = 3
prime_number_list = [2]

def is_prime(n):
	x = 2
	while n % x != 0:
		x += 1
	if x == n:
		return True

while len(prime_number_list) <= 999:
	if is_prime(n):
		prime_number_list.append(n)
	n += 1
print "The 1000th prime is:", prime_number_list[-1]

## PROBLEM 2##

from math import *

n = 3
prime_number_list = [2]
length_of_prime_number_list = 1000
input_number = 10

## Determine if a number is prime
def is_prime(n):
        x = 2
        while n % x != 0:
                x += 1
        if x == n:
                return True

## Create the list of prime numbers
while len(prime_number_list) <= length_of_prime_number_list:
        if is_prime(n):
                prime_number_list.append(n)
        n += 1


while input_number < prime_number_list[-1]:
        sum_of_logs = 0
        for item in prime_number_list:
                if item <= input_number:
                        x = log(item)
                        sum_of_logs += x
        input_number +=10

print"------------------------"
print "Number:", input_number
print "Sum of logs of primes less than input number:", sum_of_logs
print "Ratio:", sum_of_logs/input_number
print"------------------------"


jaioxung 1 year ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1
# Problem Set 0
# Name: Jaioxung
# Collaborators: none
# Time: 0:02
#

lastName = raw_input("What is your Last Name?")
firstName = raw_input("What is your First Name?")

print firstName, lastName

jaioxung 1 year ago