Power function

power[base_, exp_] :=
(
If[ exp == 1,
base,
base*power[base,exp-1]]
)

power[2,64]

Factorial function

fact[n_] :=
(
If[ n == 1,
1,
n*fact[n-1]]
)

fact[100]

Conversion to Binary Number

toBinary[n_] :=
(
If[ n > 0, 
toBinary[Quotient[n,2]]; Print[Mod[n,2]]]
)

toBinary[6]

Fibonacci Numbers

Compute the n-th Fibonacci number

Fib[n_] :=
(
If[n ≤ 2, 1, Fib[n-1]+Fib[n-2]]
)

Fib[6]

Binary Search 

Assumes that the input list is sorted from smallest to largest.

search[for_, list_, start_, stop_] :=
Module[{pos},
pos = Quotient[start + stop, 2];
If[start > stop, 
Print["not found"],
If[list[[pos]] == for, 
Print["found at ", pos],
If[list[[pos]] < for,
search[for, list, pos+1, stop],
search[for, list, start, pos-1]
]]]]

search[1,{1,2,4,5,6,7,8}, 1, 7]

Tower of Hanoi 

The ‘hanoi’ function moves a N disks from ‘from’ peg to ‘to’ peg, using ‘aux’ peg as help. The algorithm is deceptively simple:
     
         - move n-1 disks from ‘from’ peg to ‘aux’ peg to free the n-th disk
         - move the n-th disk from ‘from’ to ‘to’
         - move n-1 disks from ‘aux’ to ‘to’ to complete the problem
         
It is, consequently, implemented as a (double) recursive function:

hanoi[N_, from_, to_, aux_] :=
(
If[N ≥1,
hanoi[N-1, from, aux, to];
Print["Move disk ", N, " from " , from, " to ", to];
hanoi[N-1, aux, to, from]];
)

hanoi[3, "a", "b", "c"]