[S S T T N
_Push_-1][S S S N
_Push_0][T N
T T _Read_STDIN_as_number][N
S S N
_Create_Label_LOOP][S S S T N
_Push_1][T S S T _Subtract][S N
S _Duplicate][S S S N
_Push_0][T T T _Retrieve][S N
T _Swap][T S T T _Modulo][N
T T N
_If_0_Jump_to_Label_LOOP][S S T T N
_Push_-1][T S S N
_Multiply][T N
S T _Print_as_number]
-20 byte grazie a @JoKing .
Lettere S
(spazio), T
(scheda) e N
(nuova riga) aggiunti solo come evidenziazione.
[..._some_action]
aggiunto solo come spiegazione.
Provalo online (solo con spazi non elaborati, schede e nuove righe).
Spiegazione in pseudo-codice:
Integer n = STDIN as integer
Integer i = -1
Start LOOP:
i = i - 1
if(n modulo-i is negative)
Go to next iteration of LOOP
else
i = i * -1
Print i
Exit with error: No exit defined
Esempio di esecuzione: input = 9
Command Explanation Stack Heap STDIN STDOUT STDERR
SSTTN Push -1 [-1]
SSSN Push 0 [-1,0]
TNTT Read STDIN as integer [-1] {0:9} 9
NSSN Create Label_LOOP [-1] {0:9}
SSSTN Push 1 [-1,1] {0:9}
TSST Subtract top two (-1-1) [-2] {0:9}
SNS Duplicate top (-2) [-2,-2] {0:9}
SSSN Push 0 [-2,-2,0] {0:9}
TTT Retrieve [-2,-2,9] {0:9}
SNT Swap top two [-2,9,-2] {0:9}
TSTT Modulo top two (9%-2) [-2,-1] {0:9}
NTSN If neg.: Jump to Label_LOOP [-2] {0:9}
SSTTN Push -1 [-2,-1] {0:9}
TSST Subtract top two (-2-1) [-3] {0:9}
SNS Duplicate top (-2) [-3,-3] {0:9}
SSSN Push 0 [-3,-3,0] {0:9}
TTT Retrieve [-3,-3,9] {0:9}
SNT Swap top two [-3,9,-3] {0:9}
TSTT Modulo top two (9%-3) [-3,0] {0:9}
NTSN If neg.: Jump to Label_LOOP [-3] {0:9}
SSTTN Push -1 [-3,-1] {0:9}
TSSN Multiply top two (-3*-1) [3] {0:9}
TNST Print as integer [] {0:9} 3
error
Il programma si interrompe con un errore: nessuna uscita trovata.
n
essere 1?