kill(all)$

van=facebook.com/LearningCalculus$

op: ["+","-","*","/"]$

op[2];

f(a,b,u):=[a+b,a-b,a*b,if(b=0)then (501) else a/b][u];

f(2,f(2,2,1),1);

f(2,f(2,2,2),2);

f(2,2,2);

2-2-2;

for i:1 thru 4 do
    for j:1 thru 4 do
        if(f(2,f(2,2,i),j)=2)then
        print("Answer ", "f(2,f(2,2,",i,"),",j,")=", 2, op[i],  2, op[j], 2, "=",f(2,f(2,2,i),j));