# Expressing large numbers in index form

I have a quick question. Is there anyway of expressing a large number as a power of another number in Mathematica? By this, I mean for example, $1237940039285380274899124224 = 512^{10}$. Is there a function that enables me to go from the LHS to the RHS of the above calculation? Given $1237940039285380274899124224$, how can I obtain $512^{10}$? Divisors is close but not quite what I need.

Thanks for any useful hints.

• @John Your question doesn't make sense unless you explain why you prefer $512^{10}$ rather than $2^{90}$. This is a special case, in general your expectations are not clear at all. Jun 12, 2013 at 13:17
• @Artes, I wish to express the number in index form with the largest possible base if that makes sense-sry I wasn't explicit from the start. I wish to obtain 512^10 rather than 2^90-It's needed to solve a bigger problem. Jun 12, 2013 at 13:20
• If it helps I'm trying to solve Euler problem 119. Jun 12, 2013 at 13:25
• @John Just explain why you prefer $512^{10}$ rather than e.g. $1024^9$ or $32^{18}$. Jun 12, 2013 at 13:28
• @ Artes-here's the problem i'm trying to solve: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284. We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum. You are given that a2 = 512 and a10 = 614656. Find a30. Jun 12, 2013 at 13:32

Here's a way to brute-force search for numbers that have the property that the sum of the digits raised to an integer power is equal to the number itself.

list = {};
Do[If[Total[IntegerDigits[b^e]] == b,
AppendTo[list, {b, e}]], {b, 2, 800}, {e, 2, 100}];


This returns a list of the numbers and powers (here's just the first 50), ordered so that they are in numerical order by b^e

ord = Ordering[#[[1]]^#[[2]] & /@ list];
list[[ord]][[1 ;; 50]]

{{9, 2}, {8, 3}, {7, 4}, {17, 3}, {18, 3}, {26, 3}, {27, 3}, {22, 4}, {25, 4},
{28, 4}, {36, 4}, {28, 5}, {18, 6}, {35, 5}, {36, 5}, {46, 5}, {18, 7}, {45, 6},
{27, 7}, {54, 6}, {31, 7}, {34, 7}, {64, 6}, {43, 7}, {53, 7}, {58, 7}, {68, 7},
{46, 8}, {54, 8}, {63, 8}, {54, 9}, {71, 9}, {20, 13}, {81, 9}, {82, 10},
{85, 10},{94, 10}, {97, 10}, {106, 10}, {117, 10}, {40, 13}, {98, 11},
{107, 11}, {108, 11}, {108, 12}, {86, 13}, {103, 13}, {104, 13}, {106, 13}, {107, 13}}


and we can see that with $(8,3)=8^3$ defined as $a_2$, $(28,4)=28^4$ is $a_{10}$ and so on. The 30th is $(63,8)=63^8$.

Doing a google search I now see that this search method is well known, for instance, here and here.

It always makes me nervous using Do. Here's a one-line functional version of the above:

Select[If[Total[IntegerDigits[#[[1]]^#[[2]]]] == #[[1]], {#[[1]], #[[2]]}] &
/@ Flatten[Outer[List, Range[2, 600], Range[2, 100]], 1], UnsameQ[#, Null] &]


Set the range for the base in the first of the two Range commands and the range for the exponent in the second Range.

• thanks for posting. I've just tried the code and it seems 58^7 isnt the right answer? Not sure why. 28^4 seems to be the 14th element in your list-why is it the 10th? Jun 12, 2013 at 15:53
• I guess it wasn't obvious to me what the desired ordering is... these are ordered by base number, then exponent. I suppose it might make more sense to order them by value of base^exponent. Shouldn't be hard to sort them... Jun 12, 2013 at 15:58
• @John -- see update for reordering. Jun 12, 2013 at 16:05
• thanks for pointing that out. It does work! Thanks. Jun 12, 2013 at 16:14