This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
haas:spring2017:cprog:projects:pnc0 [2017/02/16 21:03] – [brute force] wedge | haas:spring2017:cprog:projects:pnc0 [2017/02/16 21:14] (current) – [brute force] wedge | ||
---|---|---|---|
Line 28: | Line 28: | ||
The brute force approach is the simplest to implement (and likely also the worst-performing). We will use it as our baseline (it is nice to have something to compare against). | The brute force approach is the simplest to implement (and likely also the worst-performing). We will use it as our baseline (it is nice to have something to compare against). | ||
- | To perform it, we simply attempt to evenly divide all the values between 2 and the number in question. If any one of them divides evenly, the number is **NOT** prime, but instead a composite value. | + | To perform it, we simply attempt to evenly divide all the values between 2 and one less than the number in question. If any one of them divides evenly, the number is **NOT** prime, but instead a composite value. |
Checking the remainder of a division indicates whether or not a division was clean (having 0 remainder indicates such a state). | Checking the remainder of a division indicates whether or not a division was clean (having 0 remainder indicates such a state). |