The TransCompilator

Solved LeetCode program · 66 of 1,000

#0066 · Plus One

Easy Array chunk-02.md

Original English source

The digits is a list of 1, 2, and 3. The position is the last position of digits. The carry is 1.
Repeat while position is at least 0 and carry is 1.
The sum is item position of digits plus carry. Set item position of digits to sum modulo 10. Set carry to sum divided by 10. Set position to one less than position.

For each digit in digits, show digit.

Open in Playground Browse all 1,000 problems

Expected stdout

1
2
4