共有5个数相加),几个数相加有键盘控制.
-module(test018).
-export([cal/0]).
cal()->
{ok,[Value]}=io:fread("请输入要构造的个数:","~d"),
L=[list_to_integer( lists:duplicate(X, 2 + $0) ) || X <- lists:seq(1,Value) ],
io:format("数列是:~w~n", [L]),
io:format("各项和是:~w~n", [lists:sum(L)]).