blob: 526371055f3a6e545c01855c039ddbd968b7cb9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int usrNum, usrNum1, usrNum2;
int count;
cout << "Please Enter a range: ";
cin >> usrNum1 >> usrNum2;
cout << "\nnumber\tsteps\n";
// cout << usrNum1 << "\t" << usrNum2 << endl;
for(usrNum=usrNum1; usrNum<=usrNum2; usrNum++) {
count = 0;
int initNum = usrNum;
while(initNum > 1) {
if(initNum % 2 == 0) {
initNum = initNum / 2;
}
else {
initNum = initNum*3 + 1;
}
count ++;
}
cout << usrNum << "\t" << count << "\t";
for(int x = 0; x < count; x++) {
cout << "*";
}
cout << endl;
}
}
|