elz: (ada-tubes)
[personal profile] elz posting in [community profile] intro_to_cs
First:

Open to: Registered Users, detailed results viewable to: All, participants: 25


Tickyboxes!

View Answers

Finished lecture 2
24 (96.0%)

Finished problem set 1
15 (60.0%)



Also, it occurs to me that it might be handy to have a place to post/discuss solutions to the problem sets, to see what we can learn from each other in the absence of TAs. If you actually go to MIT and the problem sets are still the same, don't read these. ;)

Fire away!

Date: 2009-11-12 08:18 pm (UTC)
yhlee: Alto clef and whole note (middle C). (Default)
From: [personal profile] yhlee
For Problem 2:

def prime_product(n):
	# first prime, followed by other prime candidates
	number = 3
	
	# the sum of all primes so far, starting with lonesome 2
	sum = math.log(2)
	
	while number <= n:
		if is_prime(number) == 1:
			sum = sum + math.log(number)
		number = number + 2
	
	print "Sum of log of primes:", sum
	print "n: ", n
	print "Ratio of sum to n:", sum/n


I'm sure this is inefficient, but there it is. :-/

Profile

Introduction to Computer Science

July 2010

S M T W T F S
    123
45678910
11121314151617
18192021222324
2526272829 3031

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 12th, 2025 01:31 pm
Powered by Dreamwidth Studios