RosettaCodeData/Task/Nth/Forth/nth.fth
2015-02-20 09:02:09 -05:00

10 lines
291 B
Forth

: 'nth ( -- c-addr ) s" th st nd rd th th th th th th " drop ;
: .nth ( n -- )
dup 10 20 within if 0 .r ." th " exit then
dup 0 .r 10 mod 3 * 'nth + 3 type ;
: test ( n n -- ) cr do i 5 mod 0= if cr then i .nth loop ;
: tests ( -- )
26 0 test 266 250 test 1026 1000 test ;
tests