From d491e7d73cad78ca80e255b80e63e11cf3df725a Mon Sep 17 00:00:00 2001 From: Kiran Ghimire <47425314+Cimihan123@users.noreply.github.com> Date: Mon, 25 Oct 2021 18:59:11 +0545 Subject: [PATCH] Added a py program It determines whether a number is a disarium or not. --- disarium.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 disarium.py diff --git a/disarium.py b/disarium.py new file mode 100644 index 0000000..f1e800e --- /dev/null +++ b/disarium.py @@ -0,0 +1,9 @@ +def is_disarium(n): + n = str(n) + value = 0 + for i in n: + power = int(n.index(str(i))) + 1 + value = value + int(i) ** power + if value == int(n): + return True + return False