From 3f9ec25ebd71a3c7d2734efb264380b7e15c3a2c Mon Sep 17 00:00:00 2001 From: VarunArora24 Date: Sun, 19 Oct 2025 19:55:21 +0530 Subject: [PATCH 1/4] Add Python function to check Disarium numbers --- maths/disarium.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 maths/disarium.py diff --git a/maths/disarium.py b/maths/disarium.py new file mode 100644 index 000000000000..f3b0ffcc4c35 --- /dev/null +++ b/maths/disarium.py @@ -0,0 +1,21 @@ +def is_disarium(num: int) -> bool: + """ + Check if a number is Disarium. + + >>> is_disarium(89) + True + >>> is_disarium(75) + False + >>> is_disarium(135) + True + """ + digits = list(str(num)) + total = 0 + for i in range(len(digits)): + total += int(digits[i]) ** (i + 1) + return total == num + + +if __name__ == "__main__": + import doctest + doctest.testmod(verbose=True) From 6b2bb3aa4bc3711a0a6f26e559c3c4b122706794 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Oct 2025 14:27:05 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/disarium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/maths/disarium.py b/maths/disarium.py index f3b0ffcc4c35..ae39ef904205 100644 --- a/maths/disarium.py +++ b/maths/disarium.py @@ -18,4 +18,5 @@ def is_disarium(num: int) -> bool: if __name__ == "__main__": import doctest + doctest.testmod(verbose=True) From 9d6142786e9bf301fcbed316992b5ea48abc5347 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 14 Sep 2026 04:22:32 +0000 Subject: [PATCH 3/4] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 1552482d70b2..751c47c41e7d 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -760,6 +760,7 @@ * [Decimal To Fraction](maths/decimal_to_fraction.py) * [Derangement](maths/derangement.py) * [Digital Root](maths/digital_root.py) + * [Disarium](maths/disarium.py) * [Dodecahedron](maths/dodecahedron.py) * [Double Factorial](maths/double_factorial.py) * [Dual Number Automatic Differentiation](maths/dual_number_automatic_differentiation.py) From 824d7ebec1a292e490bd3ba8afedb03a2975c513 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 14 Sep 2026 06:25:12 +0200 Subject: [PATCH 4/4] Add documentation link for Disarium number check Added a link to Rosetta Code for Disarium numbers. --- maths/disarium.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maths/disarium.py b/maths/disarium.py index ae39ef904205..57040a341de5 100644 --- a/maths/disarium.py +++ b/maths/disarium.py @@ -2,6 +2,8 @@ def is_disarium(num: int) -> bool: """ Check if a number is Disarium. + https://rosettacode.org/wiki/Disarium_numbers + >>> is_disarium(89) True >>> is_disarium(75)