11import { describe , expect , it } from '@jest/globals' ;
22import {
3- divisors ,
43 abundance ,
4+ divisors ,
5+ isPrime ,
56 nextPrimeFactor ,
67 primeFactors ,
8+ properDivisors ,
79 ___DIVISORS_DEFICIENT___ ,
810 ___DIVISORS_PERFECT___ ,
911 ___DIVISORS_ABUNDANT___
1012} from './divisors.js' ;
1113
12- describe ( 'divisors of a number ' , ( ) => {
14+ describe ( 'divisors and prime numbers ' , ( ) => {
1315 it ( 'divisors of one' , ( ) => {
1416 expect . assertions ( 1 ) ;
1517
@@ -35,6 +37,16 @@ describe('divisors of a number', () => {
3537 ] ) ;
3638 } ) ;
3739
40+ it ( 'proper divisors of a number' , ( ) => {
41+ expect . assertions ( 5 ) ;
42+
43+ expect ( properDivisors ( 1 ) ) . toStrictEqual ( [ ] ) ;
44+ expect ( properDivisors ( 2 ) ) . toStrictEqual ( [ 1 ] ) ;
45+ expect ( properDivisors ( 8 ) ) . toStrictEqual ( [ 1 , 2 , 4 ] ) ;
46+ expect ( properDivisors ( 9 ) ) . toStrictEqual ( [ 1 , 3 ] ) ;
47+ expect ( properDivisors ( 16 ) ) . toStrictEqual ( [ 1 , 2 , 4 , 8 ] ) ;
48+ } ) ;
49+
3850 it ( 'next prime factor of a target number' , ( ) => {
3951 expect . assertions ( 5 ) ;
4052
@@ -81,6 +93,24 @@ describe('divisors of a number', () => {
8193 } ) ;
8294 } ) ;
8395
96+ it ( 'some numbers are prime' , ( ) => {
97+ expect . assertions ( 4 ) ;
98+
99+ expect ( isPrime ( 1 ) ) . toBe ( false ) ;
100+ expect ( isPrime ( 2 ) ) . toBe ( true ) ;
101+ expect ( isPrime ( 7 ) ) . toBe ( true ) ;
102+ expect ( isPrime ( 13 ) ) . toBe ( true ) ;
103+ } ) ;
104+
105+ it ( 'some numbers are not prime' , ( ) => {
106+ expect . assertions ( 4 ) ;
107+
108+ expect ( isPrime ( 4 ) ) . toBe ( false ) ;
109+ expect ( isPrime ( 10 ) ) . toBe ( false ) ;
110+ expect ( isPrime ( 100 ) ) . toBe ( false ) ;
111+ expect ( isPrime ( 3000 ) ) . toBe ( false ) ;
112+ } ) ;
113+
84114 it ( 'abundance of a integer number' , ( ) => {
85115 expect . assertions ( 3 ) ;
86116
0 commit comments