Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83b4dd8

Browse files
authored
fix: cleanupCheckKishnamurthyNumber (#1626)
1 parent894a46c commit83b4dd8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎Maths/CheckKishnamurthyNumber.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const factorial = (n) => {
2424
constCheckKishnamurthyNumber=(number)=>{
2525
// firstly, check that input is a number or not.
2626
if(typeofnumber!=='number'){
27-
returnnewTypeError('Argument is not a number.')
27+
thrownewTypeError('Argument is not a number.')
28+
}
29+
if(number===0){
30+
returnfalse
2831
}
2932
// create a variable to store the sum of all digits factorial.
3033
letsumOfAllDigitFactorial=0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import{CheckKishnamurthyNumber}from'../CheckKishnamurthyNumber'
2+
3+
describe('CheckKishnamurthyNumber',()=>{
4+
it.each([1,2,145,40585])('returns true for %i',(num)=>{
5+
expect(CheckKishnamurthyNumber(num)).toBe(true)
6+
})
7+
8+
it.each([0,3,4,5,100,146,1019823,-1])(
9+
'returns false for %i',
10+
(num)=>{
11+
expect(CheckKishnamurthyNumber(num)).toBe(false)
12+
}
13+
)
14+
15+
it('should throw when input is not a number',()=>{
16+
expect(()=>CheckKishnamurthyNumber('2')).toThrowError()
17+
})
18+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp