User Tools

Site Tools


cs330_f2016:lab15

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs330_f2016:lab15 [2018/03/30 03:51]
morse
cs330_f2016:lab15 [2021/06/30 23:42] (current)
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: 2021/06/30 23:42 (external edit)