function f=veryfun(n)
if n==6174
    return
else
    index(1)=(n-rem(n,1000))/1000;
    index(2)=fix(n/100)-index(1)*10;
    index(3)=rem(fix(n/10),10);
    index(4)=rem(n,10);
    index2=sort(index,'ascend');
    index3=sort(index,'descend');
    a=[1000 100 10 1];
    max1=index3*(a');
    min1=index2*(a');
    max1-min1
    veryfun(max1-min1)
end