
% Program to transform decimal numbers into equivalent numbers 
% in other bases.

clear all;
% conversion to new base
Int=input('integer=');
Base=input('Base=');
Nmax=1000;
for i=1:Nmax
    % Computing the remainder of the division of Int by Base.
    aux1=Int/Base;
    Quotient=floor(aux1);
    Remainder(i)=Int-Base*Quotient;
    
    % The previous quotient is used as the starting number to 
    % compute the next digit (to the left) 
    Int=Quotient;
    if Int<=0
        break
    end
end

% Writing the digits in the right order to express the 
% equivalent new base number.

fprintf('\n New Base=%2.0f\n  ',Base);
fprintf('Rerpresentation in this base=');
for j=i:-1:1
    fprintf('%1.0f',Remainder(j));
end