// Classical Modula exponentiation namespace implementation file

#include <stdafx.h>

#include "cmodexp.h"
#include <math.h>
#include <iostream.h>

int CModexp::modexp(int a, int b, int n1)
{
	// use running product technique
	// -> no need for big integer representation
	int runprod = 1;

	for(int i = 1; i <= b; i++)
		runprod = (runprod * a) % n1;
		
	return runprod;
}

