% function to find inverse mod n
  function out=modinverse(a,n);
     x=mod(a*[1:n],n);
     out=find(x==1);
  return;


