About Me
No description provided.
Classes
|
Class status: Established
Role:
Student
|
.
17% complete
|
Submitted Assignments
 |
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 3, HW 1
##problem2
##since we can buy nuggets in x, x +1, x+5,
##in packs of 6,9,20. Which means that any large enough of ##amounts of nuggets can be bought with these sizes of ##packs as long as the first six continuous amount of ##nuggets set are established, as the 7th nugget is just ##6more than the first nugget and the 8th is 6 more than the ##2 nugget of that set
##and so on.....
##PROBLEM 3
notreachable=[]
counter=0
n=0
for n in range (6,100):
ans = False
for s in range (0,n+1):
for m in range (0,n+1):
for l in range (0,n+1):
if (6*s) + (9*m) + (20*l) == n:
ans = True
if ans:
counter +=1
if counter == 6:
print ("Largest number of McNuggets that cannot be bought in exact quantity: ",notreachable[-1])
else:
notreachable.append(n)
counter = 0
##problem 4
package = (13,17,19)
notreachable = 0
counter = 0
n = 0
for n in range (n, 200):
ans = False
for s in range (0, n+1):
for m in range (0, n+1):
for l in range (0,n+1):
if ((s*package[0]) + (m*package[1]) + (l*package[2]) == n):
ans = True
if ans:
counter+=1
if package[0] == counter:
break;
else:
counter = 0
notreachable = n
print ("Given that sizes %d, %d, and %d, the largest number of McNuggets that cannot be bought in exact quantity is: %d" % (package[0], package[1], package[2], notreachable))
Vidyaranya
10 months ago
|
 |
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1
limit = 10000
prime_list = [2]
for n in range (3, limit):
for m in range(2, n):
if n%m == 0:
break
else:
prime_list.append(n)
print ("length of list = ",prime_list)
print ("length of list = ", len(prime_list))
print ("thousand'th prime = ", prime_list[999])
print ("last prime = ", prime_list[-1])
##program 2
import math
a = 3
b = 1
c = int (input("Please Enter a Number"))
d = math.log(2)
while a < c:
v = 3
while (v < math.sqrt(a) and a%v <= 0):
v += 2
if v > math.sqrt(a):
d += math.log(a)
a += a + 2
print (d)
print (a)
w = d/ a
print (w)
Vidyaranya
10 months ago
|
 |
|
|
|