Created
February 6, 2019 09:15
-
-
Save JellyWX/37301676b52a40dd55d5064b1ae680cd 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) { | |
std::cout << "Type 2 numbers: "; | |
long num1, num2; | |
std::cin >> num1 >> num2; | |
long out = 0; | |
while (num2 != 1) { | |
std::cout << "\t" << num2 << std::endl; | |
std::cout << "\t" << num1 << std::endl; | |
if (num2 % 2 == 1) { | |
std::cout << "Add extra" << std::endl; | |
out += num1; | |
} | |
num1 = num1 << 1; | |
num2 = num2 >> 1; | |
} | |
out += num1; | |
std::cout << out << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment