Definition
Position powers
Leftmost digit uses ^1, next ^2, and so on.
A Disarium number equals the sum of its digits each raised to its left-to-right position. This tutorial covers the definition vs Armstrong, a live preview, worked Python examples, edge cases, and complexity.
Position powers
Leftmost digit uses ^1, next ^2, and so on.
89, 135
Also every one-digit number 1–9 is Disarium.
% 10 // 10
Start exponent at digit count; decrease each peel.
Different rule
Armstrong uses one fixed exponent for every digit.
Try any n
Classify positive integers instantly in the browser.
Basic check
Cache powers to bring a single check closer to O(d).
Disarium numbers are positive integers equal to the sum of their digits raised to left-to-right position powers. Classic examples: 89 (81 + 92) and 135 (11 + 32 + 53).
Every one-digit number 1–9 is Disarium because d1 = d. Do not confuse this with Armstrong numbers, which use one shared exponent equal to the digit count.
It trains digit extraction, positional indexing, and careful comparison with similar “digit power” interview problems.
Positions start at 1 on the leftmost digit.
When peeling right-to-left, start at exponent k.
All single-digit positives are Disarium.
Different exponent rule — say so in interviews.
In short: if digits are d1…dk from the left, check whether d11 + … + dkk equals n.
Given a positive integer n, decide whether it equals its position-power digit sum.
# 89 → 8**1 + 9**2 = 89 → yes
# 135 → 1**1 + 3**2 + 5**3 → yes
# 10 → 1**1 + 0**2 = 1 → no | Item | Type | Description |
|---|---|---|
n | int | Positive integer (this page excludes 0 and negatives). |
| Return / print | bool / text | True if n is Disarium. |
function is_disarium(n): // n > 0
k = number_of_digits(n)
sum = 0
pos = k
while n > 0:
digit = n mod 10
sum += digit ^ pos
pos -= 1
n = floor(n / 10)
return sum == original_n | Method | Idea | Notes |
|---|---|---|
| Right peel | % 10 / // 10 with descending exponent | Classic interview loop |
| Left-to-right string | Enumerate digits with enumerate(..., 1) | Positions match the definition directly |
| Range scan | Filter 1…N with the same helper | Great for listing 1–9 and 89 |
| Goal | Pattern |
|---|---|
| Digit count | len(str(n)) |
| Last digit | n % 10 |
| Drop last digit | n //= 10 |
| Power term | digit ** pos |
| Classic yes | 89, 135, 1…9 |
| Classic no | 10 (→ sum 1) |
Related digit problems — different exponent rules.
d_i ^ iExponent = left-to-right position
d_i ^ kSame exponent k for every digit
sum d_iNo powers — just add digits
state the ruleSay positions start at 1 on the left
Reach for Disarium checks when positional digit powers matter.
Tests digit loops and careful indexing.
Great follow-up after learning narcissistic numbers.
Print all Disarium numbers in 1…N for small N.
Makes position-dependent exponents concrete with 89 and 135.
Most lists use positive integers only — say so up front.
Key benefit: one short boolean check that forces clear thinking about digit order and exponents.
Positive integers only, within JavaScript safe range.
Three complete Python programs — single check, range scan, and left-to-right string style. Click View Output to reveal sample console results.
Right-to-left peel with descending exponents.
89)Direct and interview-friendly implementation for one input value.
def is_disarium(number: int) -> bool:
if number <= 0:
return False
original = number
digits = len(str(number))
total = 0
while number > 0:
digit = number % 10
total += digit ** digits
digits -= 1
number //= 10
return total == original
n = 89
if is_disarium(n):
print(f"{n} is a Disarium number.")
else:
print(f"{n} is not a Disarium number.") The first peeled digit is the rightmost one, so we start the exponent from the full digit count and decrease each step.
Reuse the helper to filter a beginner interval.
Prints all Disarium numbers in this range.
def is_disarium(num: int) -> bool:
if num <= 0:
return False
original = num
digits = len(str(num))
total = 0
while num > 0:
digit = num % 10
total += digit ** digits
digits -= 1
num //= 10
return total == original
print("Disarium numbers in the range 1 to 100:")
for i in range(1, 101):
if is_disarium(i):
print(i, end=" ") All one-digit positive numbers are Disarium. In two digits up to 100, only 89 matches.
Match the definition directly with string enumeration.
Positions start at 1 — no descending exponent bookkeeping.
def is_disarium_ltr(number: int) -> bool:
if number <= 0:
return False
total = 0
for pos, ch in enumerate(str(number), start=1):
total += int(ch) ** pos
return total == number
for n in (89, 135, 10, 7):
label = "Disarium" if is_disarium_ltr(n) else "not Disarium"
print(f"{n}: {label}") enumerate(..., start=1) assigns each digit its left-to-right position, which matches the mathematical definition without reversing exponents.
Set exponent to total digit count (or walk left-to-right with pos = 1…k).
Raise each digit to its position power and accumulate.
If the sum equals the original number, it is Disarium.
Equality → Disarium; otherwise not.
n = 89Trace the right-peel method. Digit count k = 2.
| Digit peeled | Exponent | Term | Running sum |
|---|---|---|---|
9 (rightmost) | 2 | 81 | 81 |
8 | 1 | 8 | 89 |
Final sum 89 equals n → Disarium.
Where Disarium checks show up beyond the interview prompt.
Digit peeling plus positional powers in one problem.
Example: write is_disarium(n).
Makes 81 + 92 memorable with a famous 89.
Example: chalkboard 89 and 135.
Clarify fixed vs positional exponents.
Example: compare 153 vs 135.
List Disarium numbers in a classroom interval.
Example: 1 to 100 → 1…9, 89.
enumerate(start=1) matches the definition cleanly.
Example: left-to-right string style.
Discuss O(d²) vs caching digit powers.
Example: precompute for large ranges.
Pro Tip: say “positions start at 1 on the left” before coding — it prevents exponent off-by-ones.
Why this pattern works well in interviews and classwork.
Position powers are easy to state on a whiteboard.
Right peel or left-to-right enumerate both work.
89 and 135 make verification quick.
Armstrong contrast and complexity caching are natural next questions.
Pro Tip: prefer left-to-right enumeration if you want the code to read exactly like the definition.
Small habits that keep Disarium solutions interview-ready.
Say left-to-right indexing starts at 1 before coding.
Save a copy before the peel loop mutates the working value.
Yes and no cases catch exponent mistakes fast.
Mention the fixed-exponent rule so interviewers know you know the difference.
Document that 0 / negatives are out of scope unless asked.
Pro Tip: if peeling from the right, whisper “start at k” — the rightmost digit always gets the largest exponent.
Mistakes that commonly break Disarium solutions.
Giving the rightmost digit power 1 when peeling from the right.
→ Start at digit count and decrease.
Using a fixed exponent equal to digit count for every digit.
→ Use position i for digit i from the left.
Comparing the sum to a mutated working variable.
→ Save original = n first.
Using enumerate without start=1.
→ Positions must begin at 1.
Many lists exclude 0; treat it as non-Disarium here.
→ Return False for n ≤ 0 unless the prompt says otherwise.
Most lists use positive numbers only; be explicit about zero and negatives.
n = 0Commonly excluded by definition; this page checks positive numbers only.
Do not use right-to-left positions directly without adjusting exponent order.
Armstrong uses fixed exponent equal to digit count for all digits.
Always Disarium because d1 = d.
A quick check when listing up to 100.
Use caching or careful bounds if scanning very large intervals.
Handy follow-ups interviewers sometimes ask.
Try these variations to lock in the pattern.
Quick Takeaway: sum each digit raised to its left-to-right position; if that equals n, it is Disarium.
| Operation | Time | Extra space |
|---|---|---|
| Single check (basic) | O(d²) | O(1) |
| Single check (cached powers) | O(d) | O(d) |
Range [1..N] | About O(N · d²) | O(1) |
A Disarium number equals the sum of its digits raised to left-to-right position powers. Peel from the right with a descending exponent, or enumerate digits from the left — then compare the sum to n.
Practice the three examples above, then continue to even numbers for a simpler divisibility warm-up.
Always save the original n, start left positions at 1, and distinguish Disarium from Armstrong.
Check positional digit powers the interview-friendly way.
d_i ^ i
DefinitionLeft starts at 1
MathRight starts at k
CodeNot Armstrong
Guard~O(d²)
AnalysisBesides 89, 135 is a classic Disarium number because 11 + 32 + 53 = 135. Every one-digit positive number 1 to 9 is Disarium.
Learn how to check whether an integer is even using modulo and bit tricks.
9 people found this page helpful