Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int number=0;
- int x=0;
- cout << "Enter a number: " ;
- cin >> number;
- if (number <= 0) {
- cout << "Input a number greater than 0";
- return 0;
- }
- while (x != 1) {
- if (number%2 == 0)
- x=number;
- else
- x = number * 3 + 1;
- }
- cout << "Your final number is: " << x << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment