Fast exponentiation and The sieve ofEratoshthenes