Skip to content

Commit

Permalink
risk big numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
AzzieDev committed Apr 10, 2023
1 parent 90509e3 commit 48de0b7
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions crypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void modeChecker(const string &moderCheck) {
modularExp();
} else if (moderCheck == "PHI" || moderCheck == "EULER") {
eulerHelper();
} else {
} else {
showModeList();

}
Expand Down Expand Up @@ -423,7 +423,6 @@ void bigMaths() {
cpp_int adder = a + b;
cpp_int subB = a - b;
cpp_int subA = b - a;
cpp_int multer = a * b;

cpp_int modB = a % b;
cpp_int divA = (a - modB) / b;
Expand All @@ -435,21 +434,31 @@ void bigMaths() {
cout << a << " + " << b << " = " << adder << endl;
cout << a << " - " << b << " = " << subB << endl;
cout << b << " - " << a << " = " << subA << endl;
cout << a << " * " << b << " = " << multer << endl;
cout << a << " / " << b << " = " << divA << " R" << modB << endl;
cout << b << " / " << a << " = " << divB << " R" << modA << endl;

//exponent calculations seem to still fail
cpp_int expA = 1;
for (cpp_int i = 0; i < b; ++i) {
expA *= a;
}
cpp_int expB = 1;
for (cpp_int i = 0; i < a; ++i) {
expB *= b;
string input;

cout << "Do you want to compute multiples? y/n" << endl;
cin >> input;
if (input[0] == 'y' || input[0] == 'Y') {
cpp_int multer = a * b;
cout << a << " * " << b << " = " << multer << endl;
cout << "Do you want to compute exponents?" << endl;
cin >> input;
if (input[0] == 'y' || input[0] == 'Y') {
//exponent calculations seem to still fail
cpp_int expA = 1;
for (cpp_int i = 0; i < b; ++i) {
expA *= a;
}
cpp_int expB = 1;
for (cpp_int i = 0; i < a; ++i) {
expB *= b;
}
cout << a << " ^ " << b << " = " << expA << endl;
cout << b << " ^ " << a << " = " << expB << endl;
}
}
cout << a << " ^ " << b << " = " << expA << endl;
cout << b << " ^ " << a << " = " << expB << endl;
}

//calculates the factorial of a given number n
Expand Down

0 comments on commit 48de0b7

Please sign in to comment.