extern crate num;

use num::bigint::BigUint;
use num::integer::Integer;
use num::traits::{One, Zero};

fn mod_exp(b: &BigUint, e: &BigUint, n: &BigUint) -> Result<BigUint, &'static str> {
    if n.is_zero() {
        return Err("modulus is zero");
    }
    if b >= n {