Confidant Numbers
Let x
be an integer of an arbitrary base, such that D
is an array of its digits. x
is a Confidant Number if, for all n
between 1
and the length of D
:
D[n+1] = D[n] + D[n-1] + ... + D[1] + n
Take, for example, the number 349
in base 10. If we label the indices for this number, we have the following.
Index Digit
----- -----
1 3
2 4
3 9
Starting from the first digit, we have 1 + 3 = 4
, which yields the next digit. Then with the second digit we have 3 + 4 + 2 = 9
, which, again, yields the next digit. Thus, this number is a Confidant Number.
Given an integer with a base between 1 and 62, calculate all the Confidant Numbers for that base, and output a list of them, separated by newlines. You can assume that there is a finite amount of Confidant Numbers for a given base.
For digits greater than 9, use the alpha characters A-Z
, and for digits greater than Z
use the alpha characters a-z
. You will not have to worry about digits beyond z
.
They do not have to be output in any particular order.
Sample Input:
16
Sample Output:
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
12
23
34
45
56
67
78
89
9A
AB
BC
CD
DE
EF
125
237
349
45B
56D
67F
125B
237F
This is code golf, so the shortest code wins. Good luck!
(Thanks to Zach for helping out with the formatting and pointing out a few problems.)
CD
not in the list? Since all other combinations where the second digit is one more than the first digit are listed, I don't understand whyCD
does not qualify. \$\endgroup\$