POSIX sh: (Dash, Bash, Zsh), (削除) 42 36 (削除ここまで) 3632 bytes (0 bytes header/footer)
-6 bytes by switching to unary, -4 bytes by swapping n and n-1 to remove an ${empty-"fallback"}
set ${2-1}1ドル2ドル 2ドル$${1-1}
trap echo\ 1ドル 0
Try it online! Try it online!
(削除) Try it online! Try it online! (削除ここまで)
We useZsh can save 1 byte by using trap [snippet]'<<<1ドル' 0 to output upon EXIT.
Explanation:
(I'm not personally a fan of${var-string} substitutes \r"string" clearing, you will see the previous lines if your terminal width$var is small enoughunset.)
(削除) Bash can save 2 bytes with
On the first loop, set ${2-1} $[2ドル+${1-1}]. (削除ここまで)1ドル2ドル is elided, so the (not in unary)first positional argument is set by ${1-1}, which triggers its the unset-fallback to 1. On each subsequent loop, the first argument is a concatenation of the two, and the second argument is the first argument from the previous iteration.
Zsh can save 1 byte by usingWe use trap '<<<1ドル'[snippet] 0 to only output upon EXIT.
POSIX sh: (Dash, Bash, Zsh), (削除) 42 (削除ここまで) 36 bytes
-6 bytes by switching to unary
set ${2-1} 2ドル${1-1}
trap echo\ 1ドル 0
Try it online!
(削除) Try it online! (削除ここまで)
We use trap [snippet] 0 to output upon EXIT.
(I'm not personally a fan of \r clearing, you will see the previous lines if your terminal width is small enough.)
(削除) Bash can save 2 bytes with (not in unary)set ${2-1} $[2ドル+${1-1}]. (削除ここまで)
Zsh can save 1 byte by using trap '<<<1ドル' 0.
POSIX sh: (Dash, Bash, Zsh), (削除) 42 36 (削除ここまで) 32 bytes (0 bytes header/footer)
-6 bytes by switching to unary, -4 bytes by swapping n and n-1 to remove an ${empty-"fallback"}
set 1ドル2ドル ${1-1}
trap echo\ 1ドル 0
Try it online!
(削除) Try it online! Try it online! (削除ここまで)
Zsh can save 1 byte by using trap '<<<1ドル' 0.
Explanation:
${var-string} substitutes "string" if $var is unset.
On the first loop, 1ドル2ドル is elided, so the first positional argument is set by ${1-1}, which triggers its the unset-fallback to 1. On each subsequent loop, the first argument is a concatenation of the two, and the second argument is the first argument from the previous iteration.
We use trap [snippet] 0 to only output upon EXIT.
POSIX sh: (Dash, Bash, Zsh), 42(削除) 42 (削除ここまで) 36 bytes
-6 bytes by switching to unary
set ${2-1} $((2ドル+$2ドル${1-1}))
trap echo\ 1ドル 0
Try it online! Try it online! (削除) Try it online! (削除ここまで)
We use trap [snippet] 0 to output upon EXIT.
(I'm not personally a fan of \r clearing, you will see the previous lines if your terminal width is small enough.)
Bash can save 2 bytes with(削除) Bash can save 2 bytes with set ${2-1} $[2ドル+${1-1}]. (削除ここまで)set ${2-1} $[2ドル+${1-1}],(not in unary)
Zsh can save 3 bytes1 byte by also using trap '<<<1ドル' 0.
POSIX sh: (Dash, Bash, Zsh), 42 bytes
set ${2-1} $((2ドル+${1-1}))
trap echo\ 1ドル 0
We use trap [snippet] 0 to output upon EXIT.
(I'm not personally a fan of \r clearing, you will see the previous lines if your terminal width is small enough.)
Bash can save 2 bytes with set ${2-1} $[2ドル+${1-1}], Zsh can save 3 bytes by also using trap '<<<1ドル' 0.
POSIX sh: (Dash, Bash, Zsh), (削除) 42 (削除ここまで) 36 bytes
-6 bytes by switching to unary
set ${2-1} 2ドル${1-1}
trap echo\ 1ドル 0
Try it online! (削除) Try it online! (削除ここまで)
We use trap [snippet] 0 to output upon EXIT.
(I'm not personally a fan of \r clearing, you will see the previous lines if your terminal width is small enough.)
(削除) Bash can save 2 bytes with (not in unary)set ${2-1} $[2ドル+${1-1}]. (削除ここまで)
Zsh can save 1 byte by using trap '<<<1ドル' 0.
POSIX sh: (Dash, Bash, Zsh), 42 bytes
set ${2-1} $((2ドル+${1-1}))
trap echo\ 1ドル 0
We use trap [snippet] 0 to output upon EXIT.
(I'm not personally a fan of \r clearing, you will see the previous lines if your terminal width is small enough.)
Bash can save 2 bytes with set ${2-1} $[2ドル+${1-1}], Zsh can save 3 bytes by also using trap '<<<1ドル' 0.