Created
September 13, 2017 18:31
-
-
Save m-byte918/d047da22a401a5a309093f0eb1ac716c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
while (true) { | |
int outsideRoot; | |
int insideRoot; | |
int d = 2; | |
std::cout << "input outside root (if none, input 1)\n"; | |
std::cin >> outsideRoot; | |
std::cout << "input inside root\n"; | |
std::cin >> insideRoot; | |
while (d * d <= insideRoot) { | |
if (insideRoot % (d * d) == 0) { | |
insideRoot = insideRoot / (d * d); | |
outsideRoot = outsideRoot * d; | |
} else { | |
d = d + 1; | |
} | |
} | |
std::cout << "the answer is: " << outsideRoot << "√" << insideRoot << "\n"; | |
std::cout << "------------------------\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment