anonymous
  • anonymous
what do you guys thin about for this answer for hw1 problem 1
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
def isprime(startnumber): startnumber*=1.0 for divisor in range(2,int(startnumber/2)+1): if startnumber/divisor==int(startnumber/divisor): return False return True number=0 prime_counter=0 max_count=9001 while(prime_counter
anonymous
  • anonymous
ignore the max count of 9001, just testing larger numbers. it does produce the right answer with correct max count.
anonymous
  • anonymous
here is problem 2 of hw1 from math import * def isprime(startnumber): startnumber*=1.0 for divisor in range(2,int(startnumber*0.5)+1): if startnumber/divisor==int(startnumber/divisor): return False return True rawnumber=input('What number N to consider? ') prime_sum_counter=0 number=0 while(number

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
post your code using dpaste.com
anonymous
  • anonymous
problem 2: for this line: for divisor in range(2,int(startnumber*0.5)+1): int(startnumber*0.5) can be expressed as startnumber/2 does this line work? if startnumber/divisor==int(startnumber/divisor) it looks like both sides of the comparison are the same python does integer division - read this and look at the note in the table for the / operator http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex what is the purpose of the second line after your while statement prime_sum_counter=prime_sum_counter please use dpaste.com to post your code. It makes it easier for everyone. goto dpast.com - paste your code in the code block - select python for the syntax - click the paste it button - post the link here, thnx put some print statements in your code and print variable values, comparison/calculation results, accumulator values ... stuff like that. It will help you see what your code is doing.
anonymous
  • anonymous
it works. the purpose of the prime_sum_counter= prime_sum_counter is to not alter the running sum if the number isn't prime.
anonymous
  • anonymous
also the function compares decimal to int so if they are equal it is a valid divisor
anonymous
  • anonymous
sorry - i missed that startnumber is a float

Looking for something else?

Not the answer you are looking for? Search for more explanations.