nitlanguage
/
nit.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
stdlib/strings: Added reversed service on Text and subclasses.
[nit.git]
/
tests
/
bench_421_ref.c
1
#include <stdio.h>
2
int
count_421
(
int
n
) {
3
int
steps
=
0
;
4
while
(
n
>
1
) {
5
steps
++;
6
if
(
n
%
2
==
0
)
7
n
/=
2
;
8
else
9
n
=
n
*
3
+
1
;
10
}
11
return
steps
;
12
}
13
14
int
main
(
int
argc
,
char
**
argv
) {
15
int
n
=
10
;
16
int
i
,
v
;
17
int
max_i
,
max_v
;
18
if
(
argc
>
1
) {
19
n
=
atoi
(
argv
[
1
]);
20
}
21
22
max_i
=
1
;
23
max_v
=
0
;
24
for
(
i
=
2
;
i
<=
n
;
i
++) {
25
v
=
count_421
(
i
);
26
if
(
v
>=
max_v
) {
27
max_i
=
i
;
28
max_v
=
v
;
29
}
30
}
31
32
printf
(
"%d: %d
\n
"
,
max_i
,
max_v
);
33
return
0
;
34
}