CS
warmup 10.htm.pdf

# warmup 10.htm.pdf - COM110 Fall 2014 Warm-up exercise 10...

• 1

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COM110 Fall 2014 Warm-­‐up exercise 10 Due Mon, Oct 13 Finish the program we started in class for prinBng out all the prime numbers between 1 and a user-­‐inpuDed value. A sample run of the ﬁnal program would be something like this: Enter a positive integer --> 20 The prime numbers up to your integer are: 1 2 3 5 7 11 13 17 19 Recall that in class we had broken the soluBon down into sub-­‐problems. First, the sub-­‐task of checking whether a single integer is prime, then the sub-­‐sub-­‐task of checking whether a number was divisible by another. So the two funcBons you need to code (and use) in addiBon to the main program, which we basically already coded together in class, have the following headers: #returns True if num is prime, returns False otherwise #recall that a number is prime if it is ONLY divisible by 1 and itself def isPrime(num): <your code here> #returns True if numerator is divisible by denominator def isDivisible(numerator, denominator): <code from class here> The isPrime() boolean funcBon is called from within the main() funcBon (as we saw in class), and the isDivisible() boolean funcBon is called from within the isPrime() funcBon. ...
View Full Document

• Fall '15
• Cannon

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern