From 90c946d4e0c0c7f9467f7a6c772df0e28e373520 Mon Sep 17 00:00:00 2001 From: Anusha-DeviE Date: Thu, 22 Jan 2026 00:45:04 +0530 Subject: [PATCH 1/5] Improve documentation and clarify edge cases for aliquot sum --- maths/aliquot_sum.nim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/maths/aliquot_sum.nim b/maths/aliquot_sum.nim index 711e24d6..2708dd4f 100644 --- a/maths/aliquot_sum.nim +++ b/maths/aliquot_sum.nim @@ -1,6 +1,15 @@ ## Aliquot sum +## ## In number theory, the aliquot sum s(n) of a positive integer n is the sum of ## all proper divisors of n, that is, all divisors of n other than n itself. +## +## For example: +## - s(12) = 1 + 2 + 3 + 4 + 6 = 16 +## - s(1) = 0 (since 1 has no proper divisors) +## +## This function is commonly used in the study of perfect, abundant, and deficient numbers. +## +## Reference: ## https://en.wikipedia.org/wiki/Aliquot_sum runnableExamples: @@ -12,8 +21,14 @@ runnableExamples: echo fmt"The sum of all the proper divisors of {number} is {sum}" func aliquotSum*(number: Positive): Natural = - ## Returns the sum of all the proper divisors of the number - ## Example: aliquotSum(12) = 1 + 2 + 3 + 4 + 6 = 16 + ## Compute the aliquot sum of a positive integer. + ## + ## Input: + ## - number: a positive integer (number > 0) + ## Output: + ## - The sum of all proper divisor of 'number' + ## Time Complexity: O(n) + ## Space Complexity: O(1) result = 0 for divisor in 1 .. (number div 2): if number mod divisor == 0: From 3f40f1d307ddaca55998deac0d326fa272906afd Mon Sep 17 00:00:00 2001 From: Anusha <135559258+Anusha-DeviE@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:28:34 +0530 Subject: [PATCH 2/5] Update maths/aliquot_sum.nim Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com> --- maths/aliquot_sum.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/aliquot_sum.nim b/maths/aliquot_sum.nim index 2708dd4f..24f3eec7 100644 --- a/maths/aliquot_sum.nim +++ b/maths/aliquot_sum.nim @@ -7,7 +7,7 @@ ## - s(12) = 1 + 2 + 3 + 4 + 6 = 16 ## - s(1) = 0 (since 1 has no proper divisors) ## -## This function is commonly used in the study of perfect, abundant, and deficient numbers. +## This function determines whether a positive integer is perfect (s(n) = n), abundant (s(n) > n), or deficient (s(n) < n). ## ## Reference: ## https://en.wikipedia.org/wiki/Aliquot_sum From 032b2d927a041b3add83bd2c1b3ad57432809c3f Mon Sep 17 00:00:00 2001 From: Anusha <135559258+Anusha-DeviE@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:29:48 +0530 Subject: [PATCH 3/5] Update maths/aliquot_sum.nim Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com> --- maths/aliquot_sum.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/aliquot_sum.nim b/maths/aliquot_sum.nim index 24f3eec7..f7fc5e87 100644 --- a/maths/aliquot_sum.nim +++ b/maths/aliquot_sum.nim @@ -27,7 +27,7 @@ func aliquotSum*(number: Positive): Natural = ## - number: a positive integer (number > 0) ## Output: ## - The sum of all proper divisor of 'number' - ## Time Complexity: O(n) + ## Time Complexity: O(number) ## Space Complexity: O(1) result = 0 for divisor in 1 .. (number div 2): From 5dd25da7c894872ef80c2831391dcee8535d57c9 Mon Sep 17 00:00:00 2001 From: Anusha <135559258+Anusha-DeviE@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:29:58 +0530 Subject: [PATCH 4/5] Update maths/aliquot_sum.nim Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com> --- maths/aliquot_sum.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/maths/aliquot_sum.nim b/maths/aliquot_sum.nim index f7fc5e87..3b4f93e1 100644 --- a/maths/aliquot_sum.nim +++ b/maths/aliquot_sum.nim @@ -30,6 +30,7 @@ func aliquotSum*(number: Positive): Natural = ## Time Complexity: O(number) ## Space Complexity: O(1) result = 0 + # A proper divisor p satisfies `number = pq` with q greater than or equal to 2 for divisor in 1 .. (number div 2): if number mod divisor == 0: result += divisor From f02fe7c30b90df57711624177361a509d2b6aa2d Mon Sep 17 00:00:00 2001 From: Anusha <135559258+Anusha-DeviE@users.noreply.github.com> Date: Sat, 24 Jan 2026 09:25:05 +0530 Subject: [PATCH 5/5] Update maths/aliquot_sum.nim Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com> --- maths/aliquot_sum.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/aliquot_sum.nim b/maths/aliquot_sum.nim index 3b4f93e1..87174900 100644 --- a/maths/aliquot_sum.nim +++ b/maths/aliquot_sum.nim @@ -26,7 +26,7 @@ func aliquotSum*(number: Positive): Natural = ## Input: ## - number: a positive integer (number > 0) ## Output: - ## - The sum of all proper divisor of 'number' + ## - The sum of all proper divisors of 'number' ## Time Complexity: O(number) ## Space Complexity: O(1) result = 0