标签:
慢慢的开始使用Mathematica软件,不过一开始总会带一些C语言的影子
No.1
Mathematica
In[21]:= Sum[x, {x, Table[If[Mod[x, 3] == 0, x, If[Mod[x, 5] == 0, x, 0]], {x, 1, 1000}]}] Out[21]= 234168
improve
In[24]:= Sum[x, {x, #1}] &@ Table[If[Mod[x, 3] == 0, x, If[Mod[x, 5] == 0, x, 0]], {x, 1, 1000}] Out[24]= 234168
improve
In[28]:= Sum[x, {x, #1}] &@ Table[If[Mod[x, #1] == 0, x, If[Mod[x, #2] == 0, x, 0]], {x, 1, #3}] & @@ {3, 5, 1000} Out[28]= 234168
No.2
标签:
原文地址:http://www.cnblogs.com/shouchengcheng/p/4237278.html