mlevy93


Joined 1 year ago
Homeworks submitted:
Homework comments:
1
1

About Me

No description provided.

Classes

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 5% complete

Submitted Assignments

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1

I wrote this program but Python identified an error that I have been struggling to correct. It would be much appreciated if someone could help me identify it.

#This program calculates the 1000 prime
count=1
prime=3
divisor=(prime-2)
while(count<1000):
    if((prime)%2)!=0:#tests if prime is odd
        while (prime%divisor)!=0 and divisor > 1:#tests if number is prime 
            divisor=divisor-2
            if not prime%divisor!=0:#if number is prime
                 prime+=2#move onto next odd number
                 count+=1#advance the count
            else prime+=2#syntax error identifid by python here!
print("The 1000 prime is", prime)
         
         

mlevy93 1 year ago