diff --git a/maths/digit_sum.ts b/maths/digit_sum.ts index 34be6730..39724081 100644 --- a/maths/digit_sum.ts +++ b/maths/digit_sum.ts @@ -9,8 +9,12 @@ */ export const digitSum = (num: number): number => { - if (num < 0 || !Number.isInteger(num)) { - throw new Error('only natural numbers are supported') + if (!Number.isInteger(num)) { + throw new Error('only integers are supported') + } + + if(num < 0) { + num *= -1; } let sum = 0