解决电力塔
a=2^Power[10^6, 10^9] 3^Power[4^9, 7^5]
TwoTower[n_] := Nest[2^# &, 1, n]
满足 TwoTower[n]>a
的最小 n
是多少?这个问题有笔和纸在Quora上回答,这里有没有办法使用Mathematica?
a=2^Power[10^6, 10^9] 3^Power[4^9, 7^5]
TwoTower[n_] := Nest[2^# &, 1, n]
What's the smallest n
such that TwoTower[n]>a
? This question had a pen-and-paper answer on Quora, is there a way to use Mathematica here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一些想法(没有仔细检查)。如果我们遵循该链接中的建议并开始记录日志(基数为 2),那么显而易见的第一件事就是我们可以安全地忘记前因子(3 的幂),因为
其中
a
是一个幂2 和b
是 3 的幂。然后,我们可以只关注 2 的幂。如果我们定义log
和power:
那么下面似乎给出了答案:
由于 NestWhile 的工作方式(最后一个元素已经违反了条件),我们减去 1,并添加 3,因为在进入 NestWhileList 之前我们已经应用了 log2 3 次。如果没有在网站上注册,我无法阅读该链接中的所有评论,因此我不知道他们的答案或正确答案是什么。
编辑:
我发现上面的解决方案可以表达得更优雅一些,这样就根本不需要人工交互:
然后,解决方案本身看起来更容易一些:
Just some thoughts (did not carefully check). If we follow the suggestion in that link and start taking logs (base 2), first thing which seems obvious is that we can safely forget the prefactor (the power of 3), since
where
a
is a power of 2 andb
is a power of 3. Then, we can focus on just the power of 2. If we define our version oflog
andpower
:Then the following seems to give the answer:
We subtract 1 due to the way NestWhile works (the last element already violates the condition), and add 3 because we applied log2 3 times already, before entering NestWhileList. I was not able to read all the comments in that link without registering on the site, so I don't know their answer or what is the correct answer.
Edit:
It occured to me that the above solution can be expressed a little more elegantly so that no human interaction is at all needed:
Then, the solution itself looks a bit easier: