Camacho numbers are positive integers that are equal to the sum of their digits raised to each power from 1 to the number of digits. For a Camacho number nN0 that consists of the digits d1d2dm, it must therefore hold that p=1m(d1p+d2p++dmp)=n

For example, 336 is a Camacho number because (3+3+6)+(32+32+62)+(33+33+63)=336

Assignment

Example

>>> camacho_term(336, 1)
12
>>> camacho_term(336, 2)
54
>>> camacho_term(336, 3)
270

>>> camacho_sum(336)
336
>>> camacho_sum(4538775)
4538775
>>> camacho_sum(183670618569)
499096875990

>>> iscamacho(336)
True
>>> iscamacho(4538775)
True
>>> iscamacho(183670618569)
False

>>> next_camacho(60)
90
>>> next_camacho(4537541)
4538775
>>> next_camacho(183670618569)
183670618662