-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3n.c
58 lines (52 loc) · 979 Bytes
/
3n.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n1,n2;
int i,j;
int valor=0;
int cont,aux;
for(;;)
{
scanf("%d %d",&n1,&n2);
if(n1==0 && n2==0)
break;
if(n1>n2)
{
i=n2;
j=n1;
}else
{
i=n1;
j=n2;
}
while(i<=j)
{
cont=1;
aux=i;
while(aux>1)
{
if(aux %2 == 0)
{
aux=aux/2;
}
else
{
aux=3*aux+1;
}
cont++;
}
if(cont>valor)
{
valor=cont;
}
i++;
}
printf("%d %d %d\n",n1,n2,valor);
n1=0;
n2=0;
valor=0;
}
return 0;
}