%  function y=fib(n,k,s)  list of n  first Fib numbers  mod k
function y=fib(n,k,a2)
if nargin==1, k=0, end
if nargin<3, a2=1, end
m=floor(n); k=abs(k);
if m<=0, y=[], return, end
if m==1, y=1, return,end
if m==2, y=[1 a2], return,end
y=ones(1,m); y(2)=a2;
for u=3:n
c=y(u-1)+y(u-2);
if c>=k, c=c-k; end
y(u)=c;
end
