program DecimalToTernary;
var decimalNumber, remainder: integer; ternaryNumber: string;
begin write('Введите десятичное натуральное число: '); readln(decimalNumber);
if decimalNumber = 0 then ternaryNumber := '0' else begin ternaryNumber := ''; while decimalNumber > 0 do begin remainder := decimalNumber mod 3; ternaryNumber := chr(remainder + ord('0')) + ternaryNumber; decimalNumber := decimalNumber div 3; end; end;
writeln('Число в троичной системе: ', ternaryNumber); end.