{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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 final 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

{[ snackBarMessage ]}