| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import trialDivision from '../trialDivision'; | |||
| 4 | 4 | * @param {function(n: number)} testFunction | |
| 5 | 5 | */ | |
| 6 | 6 | function primalityTest(testFunction) { | |
| 7 | - expect(testFunction(1)).toBeTruthy(); | ||
| 7 | + expect(testFunction(1)).toBeFalsy(); | ||
| 8 | 8 | expect(testFunction(2)).toBeTruthy(); | |
| 9 | 9 | expect(testFunction(3)).toBeTruthy(); | |
| 10 | 10 | expect(testFunction(5)).toBeTruthy(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,11 @@ | |||
| 3 | 3 | * @return {boolean} | |
| 4 | 4 | */ | |
| 5 | 5 | export 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. | ||
| 8 | 8 | return false; | |
| 9 | 9 | } else if (number <= 3) { | |
| 10 | - // All numbers from 1 to 3 are prime. | ||
| 10 | + // All numbers from 2 to 3 are prime. | ||
| 11 | 11 | return true; | |
| 12 | 12 | } | |
| 13 | 13 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments