Spasi, 141 byte
[S S S N
_Push_0][S N
S _Duplicate_0][T N
T T _Read_STDIN_as_number][T T T _Retrieve][S S S T N
_Push_1][N
S S N
_Create_Label_LOOP_1][S S S T N
_Push_1][T S S S _Add][S N
S _Duplicate][S T S S T S N
_Copy_2nd_input][S N
T _Swap_top_two][T S T T _Modulo][N
T S S N
_If_0_Jump_to_Label_BREAK_1][N
S N
N
_Jump_to_Label_LOOP_1][N
S S S N
_Create_Label_BREAK_1][S S S N
_Push_0][S T S S T S N
_Copy_2nd_input][N
S S T N
_Create_Label_LOOP_2][S N
S _Duplicate_input][S S S T N
_Push_1][T S S T _Subtract][N
T S S S N
_If_0_Jump_to_Label_BREAK_2][S N
T _Swap_top_two][S S S T N
_Push_1][T S S S _Add][S N
T _Swap_top_two][S T S S T S N
Copy_2nd_factor][T S T S _Integer_divide][N
S N
T N
_Jump_to_Label_LOOP_2][N
S S S S N
_Create_Label_BREAK_2][S N
N
_Discard_top][T N
S T _Print_as_number]
Huruf S
(spasi), T
(tab), dan N
(baris baru) ditambahkan hanya sebagai penyorotan.
[..._some_action]
ditambahkan sebagai penjelasan saja.
Cobalah online (dengan spasi, tab, dan baris baru saja).
Penjelasan dalam pseudo-code:
Integer n = STDIN as input
Integer f = 1
Start LOOP_1:
f = f + 1
if(n modulo-f == 0)
Call function BREAK_1
Go to next iteration of LOOP_1
function BREAK_1:
Integer r = 0
Start LOOP_2:
if(n == 1)
Call function BREAK_2
r = r + 1
n = n integer-divided by f
Go to next iteration of LOOP_2
function BREAK_2:
Print r as number to STDOUT
Program stops with an error: Exit not defined
Contoh dijalankan: input = 9
Command Explanation Stack Heap STDIN STDOUT STDERR
SSSN Push 0 [0]
SNS Duplicate top (0) [0,0]
TNTT Read STDIN as number [0] {0:9} 9
TTT Retrieve [9] {0:9}
SSSTN Push 1 [9,1] {0:9}
NSSN Create Label_LOOP_1 [9,1] {0:9}
SSSTN Push 1 [9,1,1] {0:9}
TSSS Add top two (1+1) [9,2] {0:9}
SNS Duplicate top (2) [9,2,2] {0:9}
STSSTSN Copy 2nd from top [9,2,2,9] {0:9}
SNT Swap top two [9,2,9,2] {0:9}
TSTT Modulo top two (9%2) [9,2,1] {0:9}
NTSSN If 0: Jump to Label_BREAK_1 [9,2] {0:9}
NSNN Jump to Label_LOOP_1 [9,2] {0:9}
SSSTN Push 1 [9,2,1] {0:9}
TSSS Add top two (2+1) [9,3] {0:9}
SNS Duplicate top (3) [9,3,3] {0:9}
STSSTSN Copy 2nd [9,3,3,9] {0:9}
SNT Swap top two [9,3,9,3] {0:9}
TSTT Modulo top two (9%3) [9,3,0] {0:9}
NTSSN If 0: Jump to Label_BREAK_1 [9,3] {0:9}
NSSSN Create Label_BREAK_1 [9,3] {0:9}
SSSN Push 0 [9,3,0] {0:9}
STSSTSN Copy 2nd from top [9,3,0,9] {0:9}
NSSTN Create Label_LOOP_2 [9,3,0,9] {0:9}
SNS Duplicate top (9) [9,3,0,9,9] {0:9}
SSSTN Push 1 [9,3,0,9,9,1] {0:9}
TSST Subtract top two (9-1) [9,3,0,9,8] {0:9}
NTSSSN If 0: Jump to Label_BREAK_2 [9,3,0,9] {0:9}
SNT Swap top two [9,3,9,0] {0:9}
SSSTN Push 1 [9,3,9,0,1] {0:9}
TSSS Add top two (0+1) [9,3,9,1] {0:9}
SNT Swap top two [9,3,1,9] {0:9}
STSSTSN Copy 2nd from top [9,3,1,9,3] {0:9}
TSTS Integer-divide top two (9/3) [9,3,1,3] {0:9}
NSNTN Jump to Label_LOOP_2 [9,3,1,3] {0:9}
SNS Duplicate top (3) [9,3,1,3,3] {0:9}
SSSTN Push 1 [9,3,1,3,3,1] {0:9}
TSST Subtract top two (3-1) [9,3,1,3,2] {0:9}
NTSSSN If 0: Jump to Label_BREAK_2 [9,3,1,3] {0:9}
SNT Swap top two [9,3,3,1] {0:9}
SSSTN Push 1 [9,3,3,1,1] {0:9}
TSSS Add top two (1+1) [9,3,3,2] {0:9}
SNT Swap top two [9,3,2,3] {0:9}
STSSTSN Copy 2nd from top [9,3,2,3,3] {0:9}
TSTS Integer-divide top two (3/3) [9,3,2,1] {0:9}
NSNTN Jump to Label_LOOP_2 [9,3,2,1] {0:9}
SNS Duplicate top (1) [9,3,2,1,1] {0:9}
SSSTN Push 1 [9,3,2,1,1,1] {0:9}
TSST Subtract top two (1-1) [9,3,2,1,0] {0:9}
NTSSSN If 0: Jump to Label_BREAK_2 [9,3,2,1] {0:9}
NSSSSN Create Label_BREAK_2 [9,3,2,1] {0:9}
SNN Discard top [9,3,2] {0:9}
TNST Print as integer [9,3] {0:9} 2
error
Program berhenti dengan kesalahan: Tidak ditemukan jalan keluar.