Skip to content

Commit 934cc5a

Browse files
committed
Use Positive as input instead
1 parent 3abe706 commit 934cc5a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

maths/aliquot_sum.nim

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ runnableExamples:
55
for number in [12, 100]:
66
echo fmt"The sum of all the proper divisors of {number} is {aliquotSum(number)}"
77

8-
func aliquotSum(number: Natural): Natural {.raises: [ValueError].} =
8+
func aliquotSum(number: Positive): Natural {.raises: [ValueError].} =
99
## Returns the sum of all the proper divisors of the number
1010
## Example: aliquotSum(12) = 1 + 2 + 3 + 4 + 6 = 16
11-
if number == 0:
12-
raise newException(ValueError, "Input number must be strictly positive")
1311
result = 0
1412
for divisor in 1 .. (number div 2) :
1513
if number mod divisor == 0:
@@ -25,7 +23,3 @@ when isMainModule:
2523
for i in 0 ..< input.len:
2624
check:
2725
aliquotSum(input[i]) == expected[i]
28-
29-
test "`aliquotSum` raises ValueError on non-positive entries":
30-
doAssertRaises(ValueError):
31-
discard aliquotSum(0)

0 commit comments

Comments
 (0)