如何在Excel中使用递归计算加泰罗尼亚数字?

发布于 2025-01-07 16:58:39 字数 297 浏览 0 评论 0原文

我尝试在 Excel 中使用 N 值执行以下操作:

http://upload.wikimedia.org/math/b/a/d/bad5db400fcfd7092e2008e376993a27.png

我可以使用=COMBIN(2*N;N)/(N+ 1),但是考虑到我的 n >= 0 如何使 ni-1 ?

谢谢

I tried to the the following in Excel using N values:

http://upload.wikimedia.org/math/b/a/d/bad5db400fcfd7092e2008e376993a27.png

I can make the Ci using =COMBIN(2*N;N)/(N+1), but how to make n-i-1 considering my n >= 0 ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心↖ 2025-01-14 16:58:39

这是可能的,但它很草率,因为 Excel 不容易允许您拥有反转数组(例如,如果您输入 B5:B1,Excel 会将其转换为 B1:B5)。

例如,用伪 Excel 表示法

C9 = C0*C8 + C1*C7 + C2*C6 + ... =“sumproduct(C0:C8, C8:C0)”

但不允许使用 C8:C0。要获得类似于 C8:C0 的东西,我们必须使用 offset 函数。您可以在 google offset 上搜索,但这里有一些示例,

ROW(B4)-ROW(B$2:B4) = 4 - [2,3,4] = [2,1,0]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 3, 1) = OFFSET(B$2, [2,1,0], 0, 3, 1) = t[B4,B3,B2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 1, 3, 1) = t[C4,C3,C2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), -1, 3, 1) = t[A4,A3,A2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 2, 1) = t[B4,B3]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 1, 1) = t[B4]

这是使用公式计算加泰罗尼亚数字的示例工作表:

   A    B
1  N   C_n
   --------
2  0   =1
3  1   =SUMPRODUCT(B$2:B2, N(OFFSET(B$2, ROW(B2)-ROW(B$2:B2),0,A3,1)))
4  2   =SUMPRODUCT(B$2:B3, N(OFFSET(B$2, ROW(B3)-ROW(B$2:B3),0,A4,1)))
5  3   =SUMPRODUCT(B$2:B4, N(OFFSET(B$2, ROW(B4)-ROW(B$2:B4),0,A5,1)))
6  4   cut-and-paste

It's possible but it's sloppy because Excel doesn't easily allow you to have reversed arrays (eg, if you enter B5:B1, Excel will convert that to B1:B5).

For example, in pseudo-Excel notation

C9 = C0*C8 + C1*C7 + C2*C6 + ... = "sumproduct(C0:C8, C8:C0)"

But C8:C0 is not allowed. To get something similar to C8:C0, we have to use the offset function. You can google offset but here are some examples,

ROW(B4)-ROW(B$2:B4) = 4 - [2,3,4] = [2,1,0]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 3, 1) = OFFSET(B$2, [2,1,0], 0, 3, 1) = t[B4,B3,B2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 1, 3, 1) = t[C4,C3,C2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), -1, 3, 1) = t[A4,A3,A2]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 2, 1) = t[B4,B3]
OFFSET(B$2, ROW(B4)-ROW(B$2:B4), 0, 1, 1) = t[B4]

Here is a sample worksheet to calculate the Catalan numbers using your formula:

   A    B
1  N   C_n
   --------
2  0   =1
3  1   =SUMPRODUCT(B$2:B2, N(OFFSET(B$2, ROW(B2)-ROW(B$2:B2),0,A3,1)))
4  2   =SUMPRODUCT(B$2:B3, N(OFFSET(B$2, ROW(B3)-ROW(B$2:B3),0,A4,1)))
5  3   =SUMPRODUCT(B$2:B4, N(OFFSET(B$2, ROW(B4)-ROW(B$2:B4),0,A5,1)))
6  4   cut-and-paste
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文