** memory layout:
* OICag
* O: outer loop counter ( 50 downto 1 )
* I: inner loop counter ( 26 downto 1 )
* C: output character
* a: case flag ( minus 1 if upper case 0 if lower case )
* g: global counter ( 0 to 1299 )
**
* outer loop ( input a SP(32) )
,[-->+++<]>O++[-
* inner loop ( duplicate comma to skip a NL )
>,,I++>+++++[-<+++++>]<I[
I[->C->+<<]
>>-[-<<I+>>]
* create a capital alphabet
+++++++[-<C+++++++++++++>]
* switch with g
* if 0 ( 1 ) do nothing
* else judge if g plus 1 is prime / has some "3" digit
* memory layout:
* agG
* G: backup of g
>g[
* set minus 1 ( default: upper ) to a
<a->
* memory layout:
* a_G_nm
* n m: g plus 1
* copy g plus 1 to n and m
g+[->G+>>n+m>+<<<<]
>G-
>>>m[
* divmod m by 10
* memory layout:
* a_g_nmdrq
* d: dividor(10) then 10 minus r
* r: reminder
* q: quotient
>d++++++++++<m[->-[>+>>]>[+[-<+>]>+>>]<<<<<]
* if r=3 ( lower case ) increment a and clear d q n
>>r---[,+d<,+r>]<d[,+>>q,+<<<<n,+<<<<a+>>>>>>]
* move q to m
>>q[-<<<m+>>>]
<<<m]
* prime judge
* subtract d*d from n ( underflow aware ) then judge if n is divisible by d
* memory layout:
* a_G_nd
* d: incremental odd divider ( set 0 when the judge ends )
d+[+
* memory layout:
* a_G_nd
* a_GNc__Ddn
* N: a copy of n
* c: loop counter ( initially d )
* D: counterblnce of d
* move n
<[-<N+>>>>>>n+<<<<<]
* move d
>[-<+>>>>+<<<]
* subtraction loop
<c[-
>>>>d[
>[n-<<D+<]
* clear d D when underflow detected
<[d,++<,+<<]
>>>d-]
* restore d from D ( when no underflow occurred )
<D[->d+<]
<<<c]
* judge if n minus d*d is divisible by d
* memory layout:
* a_GNn__rdx
* x: n minus d*d
* r: reminder of x/d
* restore original n
<N[->n+<]
>>>>>d[
* mod x by d ( no quotient )
>x[-<-[<+<]<[+[->+<]<<]>>>>]
* restore original d from r d when x is not divisible by d
<<r[[-<<+>>]>d[-<<<+>>>]<r]
* when divisible clear d and increment a
>d[,+<<<<<<<<a+>>>>>>>>d]
d]
<<<d] ** notice this d is at the original place
** clear n
<n,+<<<
g]
* restore g from G ( and increment )
>G+[-g<+>]
* tolower
<<a+[+++[-<c++++++++>]]
* putc
<C.,+
<I]
<O]