% approxexpmod.m
%
%

kmax = input('\nInserire il massimo k:\n');

clc

e=exp(1);

fid = fopen('tabellaexp.txt', 'w');

disp(sprintf('\nn\t f(n)\t\t Errore'));

fprintf( fid, '\nn\t f(n)\t\t Errore\n' );

for k=0:2:kmax
   n=10^k;
   fn=(1+1/n)^n;
   errore=abs(e-fn);
   fprintf('%2.1e\t %11.10f\t %e\n',n,fn,errore);
   
   fprintf(fid, '%2.1e\t %11.10f\t %e\n',n,fn,errore);
   
end

fclose(fid);

% stampa in un file la tabella
% tabellaexp.txt