% Script P2
% Counts the number of "excellent integerss" less than M
M = input('Enter a positive integer: ');
count = 0;
% The highest possible power of three...
alfa = floor(log(M)/log(3));
for j=0:alfa
M1 = M/3^j;
% The highest power of two <= M1 plus 1...
beta = floor(log(M1)/log(2))+1;
count = count+beta;
end
disp(' ')
fprintf('There are %1d excellent numbers <= %1d\n',count,M)