We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bc7e8cc + 638a7e3 commit 175c8fbCopy full SHA for 175c8fb
disarium.py
@@ -0,0 +1,20 @@
1
+def calculateLength(n):
2
+ length = 0;
3
+ while(n != 0):
4
+ length = length + 1;
5
+ n = n//10;
6
+ return length;
7
+
8
+num = 175;
9
+rem = sum = 0;
10
+len = calculateLength(num);
11
+n = num;
12
+while(num > 0):
13
+ rem = num%10;
14
+ sum = sum + int(rem**len);
15
+ num = num//10;
16
+ len = len - 1;
17
+if(sum == n):
18
+ print(str(n) + " is a disarium number");
19
+else:
20
+ print(str(n) + " is not a disarium number");
0 commit comments