applied_numerics_uulm/w1/matlab/convert2basis.m

18 lines
238 B
Mathematica
Raw Normal View History

2022-05-15 20:14:40 +00:00
% EX2 a)
function a = convert2basis(n, b)
if (b < 2)
disp('basis needs to be at least 2!')
return
end
v = [];
while n > 0
v = [mod(n, b), v];
n = floor(n / b);
end
a = v
end