Math 返回格式x^y的第i个数字,其中x和y是整数

Math 返回格式x^y的第i个数字,其中x和y是整数,math,wolfram-mathematica,sequence,dynamic-programming,exponent,Math,Wolfram Mathematica,Sequence,Dynamic Programming,Exponent,x和y是大于1的整数。 特殊数字可以表示为x^y。 请注意,特殊数字序列是按升序排列的(4、8、9、16、25、27、32等)。 给定一个整数i,程序应返回第i个特殊数字 i=0 -> num=4 i=4 -> num=25 我想要一些见解。在一个公司的编码回合中面对这一点。野蛮的武力最终导致了恐怖袭击 编辑1:找到链接: 编辑2:我分享了codegolf链接,以帮助检查一些已经可用且预计将超过时间限制的解决方案。我尝试了Mathematica解决方案和sage解决方案,在这两种方

x和y是大于1的整数。 特殊数字可以表示为x^y。 请注意,特殊数字序列是按升序排列的(4、8、9、16、25、27、32等)。
给定一个整数i,程序应返回第i个特殊数字

i=0 -> num=4
i=4 -> num=25
我想要一些见解。在一个公司的编码回合中面对这一点。野蛮的武力最终导致了恐怖袭击

编辑1:找到链接:


编辑2:我分享了codegolf链接,以帮助检查一些已经可用且预计将超过时间限制的解决方案。我尝试了Mathematica解决方案和sage解决方案,在这两种方法上都遇到了问题。

这个问题相当于找到一个整数
j
,其中
log_j k
是一个整数,
j
是一个上界为
k
的序列,使得
sum[floor(log_j k)-1 | j这是离题的。您所做的只是重新发布一个代码高尔夫问题,没有显示出解决问题的努力(更不用说给出了一行mathematica解决方案)注意代码高尔夫问题允许
x=1
,因此解决方案需要(微不足道)调整。
m
Guess: 10^2
Highest base: 10

Then at minimum we have (10 - 1) + (floor(log2 (10^2)) - 1)
= 15 elements. Too many.


Guess: 5^2 
Highest base: 5
Minimum element count: (5 - 1) + (floor(log2 (5^2)) - 1) = 8

Iterate over logs:
  -- Because of the exponential nature of the problem,
  -- if the guess is too large, the bulk of the elements will appear
  -- early in the iteration; and if it's too small, the limit on
  -- exponents will drop early allowing for early exit in either case.

  [floor(logBase x 25) - 1 | x <- [2..4]] = [3,1,1]
  sum ([1] ++ [3,1,1]) = 6. Too few.


Guess: 7^2
Highest base: 7
Minimum element count: (7 - 1) + (floor(log2 (7^2)) - 1) = 10

Iterate over logs:
  [floor(logBase x 49) - 1 | x <- [2..6]] = [4,2,1,1,1]
  sum ([1] ++ [4,2,1,1,1]) = 10

Answer: 7^2