# BYU CS classes

### Site Tools

cs330_f2016:lab15

# Differences

This shows you the differences between two versions of the page.

 cs330_f2016:lab15 [2018/03/29 20:51]morse cs330_f2016:lab15 [2018/04/04 15:31] (current)morse Both sides previous revision Previous revision 2018/04/04 15:31 morse 2018/03/29 20:51 morse 2016/11/30 13:11 wingated [Hints:] 2016/11/28 14:51 morse 2016/11/28 13:19 wingated [Resources:] 2016/11/23 18:04 morse [Hints:] 2016/11/23 18:02 morse [Resources:] 2016/11/23 09:51 morse 2016/11/23 09:44 morse 2016/11/23 09:13 morse 2016/11/21 22:04 morse 2016/11/21 22:02 morse 2016/11/21 21:49 morse 2016/11/21 21:25 morse 2016/11/15 11:55 morse 2016/11/08 10:27 wingated created 2018/04/04 15:31 morse 2018/03/29 20:51 morse 2016/11/30 13:11 wingated [Hints:] 2016/11/28 14:51 morse 2016/11/28 13:19 wingated [Resources:] 2016/11/23 18:04 morse [Hints:] 2016/11/23 18:02 morse [Resources:] 2016/11/23 09:51 morse 2016/11/23 09:44 morse 2016/11/23 09:13 morse 2016/11/21 22:04 morse 2016/11/21 22:02 morse 2016/11/21 21:49 morse 2016/11/21 21:25 morse 2016/11/15 11:55 morse 2016/11/08 10:27 wingated created Line 25: Line 25: IsPrime takes integer n and returns true if n is prime, false otherwise. IsPrime takes integer n and returns true if n is prime, false otherwise. - You can test to see if a number is prime by testing for divisibility by integers greater than one and less than or equal to the square root of the number being tested. ​ + You can test to see if a number is prime by testing for divisibility by integers greater than one and less than or equal to the square root of the number being tested. For convenience,​ the function ''​ISqrt'',​ which computes this largest integer less than the square root of n, has been provided for you below in the Hints section. ==primes== ==primes== Line 46: Line 46: ​ Takes an integer n and returns true if n is prime. Takes an integer n and returns true if n is prime. + Unlike isPrime, which tests for divisibility by all integers between 2 and the square root of n, it tests for divisibility using only prime numbers in this range. **Only test prime factors from the primesFast list.** **Only test prime factors from the primesFast list.**