Revision as of 18:40, 5 February 2009 by Jbolande (Talk | contribs)


I wrote a program in C++ to calculate the numbers generated for a ( a.k.a <a>={ A, ... , B }) I can send you the program if you want it. My email is tmcqueen@purdue.edu. Here is the code for it though. The Number of cycles is how many powers will be generated. Im sure there are better ways to do some of the stuff I just don't know them. And there is a limitation to the program. If numbers get to large the program can't use them(i.e. 13^15 will most likley give problems). It has to do with data types, and what the operations can be done to them, and how large a data type can be.

-Tyler McQueen


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	float base,  cycles, n = 1, t;
	int modulus;

	cout << "Enter generator (a from <a>):";
	cin >> base;
	cout << "\n";

	cout << "Enter modulus:";
	cin >> modulus;
	cout << "\n";

	cout << "Enter number of cycles:";
	cin >> cycles;
    cout << "\n";

while (n-1 < cycles)
{
    long double x;
		x = (pow(base,n));
	int y;
		y=floor(x);
if(x==y)
{
	cout << base << "^" << n << " = " ;
    cout << y%modulus  << endl ;
	//cout << "power=" << n  << endl;
	//cout << "x=" << x  << "  ";
	//cout << "y=" << y  << endl;
	n++;
}
if(x != y)
{
	cout << " Numbers to large\n Last two numbers may not be correct\n\n" << endl;
	n = cycles+1;
}
}
cout << "Enter a number to end porgram:";
cin >> t ;

	return 0;
}


Wow! I just wanted to say wow and thanks for sharing this! -Josie

Alumni Liaison

Meet a recent graduate heading to Sweden for a Postdoctorate.

Christine Berkesch