Your loop is not needed (and is problematic). The combinat:-choose
command returns all of them, so there's no looping required.
F:=proc(n)
nops(combinat:-choose({$2..n},3));
end proc:
Or, closer to your original code,
g:=proc(n)
local x,setG,setG2;
setG:={seq(x+1,x=1..n-1)};
setG2:=combinat:-choose(setG,3);
nops(setG2);
end proc:
A very similar homework problem was asked today on another forum, with the additional caveat that the subsets each contained at least one odd integer.
H:=proc(n)
nops(select(hastype,combinat:-choose({$2..n},3),odd));
end proc:
Or, closer to your original style,
h:=proc(n)
local x,setG,setG2,setG3;
setG:={seq(x+1,x=1..n-1)};
setG2:=combinat:-choose(setG,3);
setG3:=select(hastype,setG2,odd);
nops(setG3);
end proc: