u_dekadnu x b1 = if x==0 then 0 else u_dekadnu (x `div` 10) b1 * b1 + (mod x 10) 

iz_dekadne x b2 = if x==0 then 0 else iz_dekadne (x `div` b2) b2 * 10 + (mod x b2)

promeni_zapis x b1 b2 = if b1/=10 then iz_dekadne (u_dekadnu x b1 ) b2 else iz_dekadne x b2