mirror of
https://github.com/danog/ton.git
synced 2024-12-04 10:28:27 +01:00
13 lines
152 B
Plaintext
13 lines
152 B
Plaintext
int steps(int x) {
|
|
var n = 0;
|
|
while (x > 1) {
|
|
n += 1;
|
|
if (x & 1) {
|
|
x = 3 * x + 1;
|
|
} else {
|
|
x >>= 1;
|
|
}
|
|
}
|
|
return n;
|
|
}
|