Advertisement
monito2207

Untitled

Nov 21st, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int startNum, finalNum, count = 0;
  6. cin >> startNum >> finalNum;
  7.  
  8. while (finalNum > startNum) {
  9. count++;
  10. if (finalNum % 2 == 0) {
  11. finalNum /= 2;
  12. }
  13. else if (finalNum % 2 == 1) {
  14. finalNum += 1;
  15. }
  16. }
  17.  
  18. count = count + startNum - finalNum;
  19. cout << count;
  20.  
  21.  
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement