我很难理解彩色大理石的递归问题。任务是确定在特定递归级别上每种颜色有多少种大理石(总共有三种颜色)。 (级别由用户输入)。我做了这样的事情,尽管我怀疑它是否完全有效:
Public sub marbles(r as Integer, o as Integer, g as Integer, n as integer) 'In this case r is red, o is orange and g is green)
dim rr, oo, gg as Integer
rr = 2*r + 1*o + 3*g
oo = 1*r + 3*o + 2*g
gg = 3*r + 2*o + 1*g
public sub Button
dim rr, oo, gg, n as Integer
n=Val(InputBox("Enter the preferred level"))
marbles(rr,oo,gg)
n是完成递归的次数。在n次递归后如何输出每种彩色大理石的结果量?