-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5x+1.cpp
More file actions
46 lines (44 loc) · 792 Bytes
/
5x+1.cpp
File metadata and controls
46 lines (44 loc) · 792 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
using namespace std;
int main()
{
// int hour = 8;
int random;
int steps=0;
while(cin>>random)
{
steps=0;
// while (random > 1)
do {
if (random % 2 == 0)
{
//random = random * 3 + 1;
random = random/2;
cout<<random<<", ";
steps++;
}
else if (random %3 == 0)
{
//random = random / 2;
random = random/3;
cout<<random<<", ";
steps ++;
}
else
{
random = 5*random + 1;
cout<<random<<", ";
steps ++;
}
/* if (hour - random > 4)
{
if (hour + random < 11)
{
printf("Malicious Behavior!\n");
}
}*/
}while(random > 1);
cout<<endl<<"Total loop steps:"<<steps<<endl;
}
return 0;
}