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

fix: cleanupCheckKishnamurthyNumber#1626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletionMaths/CheckKishnamurthyNumber.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,10 @@ const factorial = (n) => {
const CheckKishnamurthyNumber = (number) => {
// firstly, check that input is a number or not.
if (typeof number !== 'number') {
return new TypeError('Argument is not a number.')
throw new TypeError('Argument is not a number.')
}
if (number === 0) {
return false
}
// create a variable to store the sum of all digits factorial.
let sumOfAllDigitFactorial = 0
Expand Down
18 changes: 18 additions & 0 deletionsMaths/test/CheckKishnamurthyNumber.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
import { CheckKishnamurthyNumber } from '../CheckKishnamurthyNumber'

describe('CheckKishnamurthyNumber', () => {
it.each([1, 2, 145, 40585])('returns true for %i', (num) => {
expect(CheckKishnamurthyNumber(num)).toBe(true)
})

it.each([0, 3, 4, 5, 100, 146, 1019823, -1])(
'returns false for %i',
(num) => {
expect(CheckKishnamurthyNumber(num)).toBe(false)
}
)

it('should throw when input is not a number', () => {
expect(() => CheckKishnamurthyNumber('2')).toThrowError()
})
})

[8]ページ先頭

©2009-2025 Movatter.jp