31
1
Disarium Dilemma
A Disarium is defined as a number whose:
sum of its digits powered with their respective position is equal to the original number
Your Task:
You have a strange obsession with numbers classified as being a disarium. The need to follow the ways of disarium is so great in you that you refuse to read any non-disarium numbered pages in any given book. You have two BIG problems:
- Your professor just assigned you to read your textbook from page
n
to pagem
- You hit your head really hard last week and can't seem to remember how to programmatically determine if a number is considered to be a disarium.
Time is of the essence so the code to determine the pages you will need to read needs to be as short as possible.
You need to identify all of the disarium within an inclusive range of n
through m
.
Examples of a disarium:
89 = 81 + 92
135 = 11 + 32 + 53
518 = 51 + 12 + 83
This is code-golf, so the least number of bytes wins!
Here is the full sequence of A032799.
@Fatalize The range is inclusive, I will edit the question to reflect this. – CraigR8806 – 2017-01-19T13:51:25.857
Are there any guaranteed bounds on
n
andm
? There’s a very big disarium (12157692622039623539), should answers be able to identify it? – Lynn – 2017-01-19T15:12:58.400@Lynn Given that there are already a number of solutions, I would say there should be no bounds on the range. – CraigR8806 – 2017-01-19T15:17:49.443
2@Lynn. There is no disarium >22 digits, so in a way the range is already bounded. – Mad Physicist – 2017-01-19T16:21:29.293
OEIS link to disarium numbers, for anyone interested. – Carmeister – 2017-01-19T18:39:36.820
Are we guaranteed that
a
andb
are both larger than 0? – FlipTack – 2017-01-19T20:12:06.283@MadPhysicist Why would that be the case? Can you link to a proof (if there is one), I'm genuinely interested. Thanks! – MildlyMilquetoast – 2017-01-19T20:54:55.273
@FlipTack If
n
andm
are negative, it shouldn't return any values as is the nature of the sequence. – CraigR8806 – 2017-01-19T20:57:16.3633@MistahFiggins Please go to the OEIS link at the bottom of the question. You will find a proof that shows the Disarium sequence is indeed finite. – CraigR8806 – 2017-01-19T20:58:06.490