悠闲数学娱乐论坛(第2版)'s Archiver

其妙 发表于 2014-7-1 22:56

列举数列的前100项

i = 1;
a[1] = 2;
a[2] = 6;
Do[{a[i + 2] = 2 a[i + 1] + a[i], i++}, {100}]
Table[a[n], {n, 1, 100}]
out:
{2, 6, 14, 34, 82, 198, 478, 1154, 2786, 6726, 16238, 39202, 94642, 228486, 551614, 1331714, 3215042, 7761798, 18738638, 45239074, 109216786, 263672646, 636562078, 1536796802, 3710155682, 8957108166,21624372014, 52205852194, 126036076402, 304278004998, 734592086398, 1773462177794, 4281516441986, 10336495061766, 24954506565518, 60245508192802, 145445522951122, 351136554095046, 847718631141214, ……
i = 1;
a[1] = 3;
a[2] = 9;
Do[{a[i + 2] = a[i + 1] + 2 a[i], i++}, {100}]
Table[a[n], {n, 1, 100}]
out:{3, 9, 15, 33, 63, 129, 255, 513, 1023, 2049, 4095, 8193, 16383, 32769, 65535, 131073, 262143, 524289, 1048575, 2097153, 4194303, 8388609, 16777215, 33554433, 67108863, 134217729, 268435455, 536870913, 1073741823, 2147483649, 4294967295, 8589934593, 17179869183, 34359738369, 68719476735, ……

青青子衿 发表于 2014-7-2 20:03

[b]回复 [url=http://kuing.orzweb.net/redirect.php?goto=findpost&pid=10569&ptid=2880]1#[/url] [i]其妙[/i] [/b]
可以试着用把字符变成代码(Mathematics代码)[code]i = 1;
a[1] = 2;
a[2] = 6;
Do[{a[i + 2] = 2 a[i + 1] + a[i], i++}, {100}]
Table[a[n], {n, 1, 100}][/code]

其妙 发表于 2014-7-7 22:08

[b]回复 [url=http://kuing.orzweb.net/redirect.php?goto=findpost&pid=10574&ptid=2880]2#[/url] [i]青青子衿[/i] [/b]

一样的嘛

isee 发表于 2017-10-12 14:29

这个也顶上来,哈哈,核心,Mathematica的核心。。。

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.