Common forumla

Factorial

 * factorial ( n -- n!, replaces n with the factorial of n ) { | ACC } 1 +-> ACC

begin dup ACC * -> ACC 1 -    dup 0= until drop ACC ;

Calculation of PI
Utilizes the floating point stack


 * PI ( -- PI, puts pi on the float stack ) 1.0 fatan 4.0 f* ;

Example:


 * PI ( -- PI, puts pi on the float stack ) 1.0 fatan 4.0 f* ;   ok

Stack<10> PI   ok Stack<10> f.s FP> 3.141593 ok

Fibonacci
linear implementation lends itself well to the use of stacks
 * fib ( n -- f[n], Fibonacci series starting at f[0] = 1, f[1] = 1)

DUP DUP 0= \ n n n=0 SWAP 1 = \ n n=0 n=1 OR \ n n=0|n=1 IF \ n, base case DROP 1 \ f[n] ELSE \ n, non-base case 1 1 ROT \ 1 1 n		1 DO \ 1 1, I			\ f[I-1] f[I] DUP ROT \ f[I] f[I] f[I-1] + \ f[I] f[I+1] LOOP \ f[n-1] f[n] SWAP DROP \ f[n] THEN

Exponent
Integer exponentiation: : int^int ( x y -- x^y ) 1 SWAP 0 DO     OVER * LOOP SWAP DROP