File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
src/algorithms/math/primality-test Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import trialDivision from '../trialDivision';
44 * @param {function(n: number) } testFunction
55 */
66function primalityTest ( testFunction ) {
7- expect ( testFunction ( 1 ) ) . toBeTruthy ( ) ;
7+ expect ( testFunction ( 1 ) ) . toBeFalsy ( ) ;
88 expect ( testFunction ( 2 ) ) . toBeTruthy ( ) ;
99 expect ( testFunction ( 3 ) ) . toBeTruthy ( ) ;
1010 expect ( testFunction ( 5 ) ) . toBeTruthy ( ) ;
Original file line number Diff line number Diff line change 33 * @return {boolean }
44 */
55export default function trialDivision ( number ) {
6- if ( number <= 0 ) {
7- // If number is less then one then it isn't prime by definition.
6+ if ( number <= 1 ) {
7+ // If number is less than one then it isn't prime by definition.
88 return false ;
99 } else if ( number <= 3 ) {
10- // All numbers from 1 to 3 are prime.
10+ // All numbers from 2 to 3 are prime.
1111 return true ;
1212 }
1313
You can’t perform that action at this time.
0 commit comments