Revision as of 10:25, 3 February 2009 by Tmcqueen (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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.


  1. include <iostream>
  2. 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; }

Alumni Liaison

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin