Guest User

Untitled

a guest
Sep 12th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.  
  7. int number=0;
  8. int x=0;
  9.  
  10. cout << "Enter a number: " ;
  11. cin >> number;
  12.  
  13. if (number <= 0) {
  14. cout << "Input a number greater than 0";
  15. return 0;
  16. }
  17.  
  18. while (x != 1) {
  19. if (number%2 == 0)
  20. x=number;
  21.  
  22. else
  23. x = number * 3 + 1;
  24.  
  25. }
  26.  
  27. cout << "Your final number is: " << x << endl;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment