I had gotten it to work with some numbers, mainly base 2 power 3 but not others, mainly base 5 power 4. Now I messed around with it and it always prints 0.
Here is the first code I came up with that works with base 5 power 4 but not base 2 power 3:
Code:
#include <iostream>
using namespace std;
int main ( ) {
int base;
int power;
int result = 0;
cout << "enter base: ";
cin >> base;
cout << "enter POWER: ";
cin >> power;
for(int lvar = 1; lvar <= power; lvar++) {
// cout << lvar;
// cout << endl;
lvar = base * base;
// cout << lvar;
// cout << endl;
result = lvar * base * base;
}
cout << result;
}
Here is the latest code:
Code:
#include <iostream>
using namespace std;
int main ( ) {
int base;
int power;
int result = 0;
cout << "enter base: ";
cin >> base;
cout << "enter POWER: ";
cin >> power;
// int track = 0;
for(int lvar = 1; lvar <= power; lvar++) {
// result = lvar * result;
// cout << lvar;
// cout << endl;
for(int track = 0; track <= lvar; track++) {
base = base * base;
}
result = base * base;
// cout << lvar;
// cout << endl;
// result = result * base * base;// power * lvar * result; // lvar * base * base;
}
cout << result;
}