cs330_f2016:lab15

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

Both sides previous revision Previous revision | |||

cs330_f2016:lab15 [2018/03/29 20:51] morse |
cs330_f2016:lab15 [2018/04/04 15:31] (current) morse |
||
---|---|---|---|

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: | ||

</code> | </code> | ||

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.** | ||

cs330_f2016/lab15.txt ยท Last modified: 2018/04/04 15:31 by morse