gpt4 book ai didi

algorithm - 需要协助证明嵌套循环和指数

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:14:42 24 4
gpt4 key购买 nike

是否可以将任何嵌套循环的增长表示为指数?这是我和几个同学的讨论。我试图使用指数定律证明:

If n = the size of the outer loop
If k = the size of the inner loop

Then, if we use n as our base and the value of n is n^1:
Then, if n^x = k, the total = n^(1+x) for any n and k.

这应该适用于我认为的任何基地。此外,只要您使用相同的基数,外环在技术上可以提升到任何幂。

编辑:用于澄清的代码示例:

for (int i =1; i <= n; i++){

for (int j = 1; j <= k; j++){

/// whatever

}

}

Let us say that:
n = 10
k = 5

We would expect that the total would be 10 * 5 = 50
50 maximum loops

I am saying that:
10 = 10^1 -> outer loop
5 = 10^.69897 -> inner loop
10^1.69897 = 50

这应该适用于任何基地。

最佳答案

我不确定这与循环有什么关系,但通常假设您有任意两个数字,nk,并且您想表示 n*kn 为基数:

n 将在基数 n 处为 10k 将是 10^(log k)(log 这里表示以 10 为底的对数)

所以 n*k = 10 * 10^(log k) = 10^(log k + 1)所以是的,数学成立。但我不确定您为什么选择这样看待它。

关于algorithm - 需要协助证明嵌套循环和指数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42887427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com