rs031759


Joined 1 month ago

About Me

No description provided.

Classes

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Under Construction
Role: Student
. 16% complete

Submitted Assignments

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1
# Problem Set 1 part one
# Find prime number
# Name: Ricky Sumarto
# Time: 10 minutes
#

inp = int(raw_input("Input integer 1-1000? "))
print "Your number is : " , inp

# Find odd number and put into array
Odd=[]
for x in range (2,inp+1):
    if ((x%2)!=0):
     Odd.append(x)
print "Load odd values array", Odd

# Find prime number
prime=[]

for x in range(0, len(Odd)):
     number=Odd[x]
     accum=0

     for y in range(0, x):
        if (number%Odd[y]==0):
         accum=accum+1
     if accum<=2:
         prime.append(number)
print "Your prime number: ", prime


# Problem Set 1 part two:
# Calculate the log
# =========================================
totLog=0
for x in range(0, len(prime)):
    totLog = totLog + log(prime[x], 10)
      
print 'Sum of log n:', totLog
print 'The number n is: ', inp
print 'Ratio the 2 numbers is: ', totLog/inp

rs031759 4 weeks ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1

Problem Set 0

Name: Ricky Sumarto

Time: 10 minutes

fname=str(raw_input("Enter your first name: ")) lname=str(raw_input("Enter your last name: ")) print ("Your name is " + fname + " " + lname)

# Problem Set 0
# Name: Ricky Sumarto
# Time: 10 minutes
#
fname=str(raw_input("Enter your first name: "))
lname=str(raw_input("Enter your last name: "))
print ("Your name is " + fname + " " + lname)

rs031759 4 weeks ago