(New page: Category:MA453Spring2009Walther 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 tm...) |
|||
Line 3: | Line 3: | ||
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. | 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. | ||
− | + | <pre> | |
#include <iostream> | #include <iostream> | ||
Line 53: | Line 53: | ||
return 0; | return 0; | ||
} | } | ||
− | + | </pre> | |
[[Category:MA453Spring2009Walther]] | [[Category:MA453Spring2009Walther]] |
Revision as of 09:27, 3 February 2009
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.
#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; }