Skip to content

Instantly share code, notes, and snippets.

@rigibun
Last active August 29, 2015 13:56
Show Gist options
  • Save rigibun/9250790 to your computer and use it in GitHub Desktop.
Save rigibun/9250790 to your computer and use it in GitHub Desktop.
import std.stdio, std.conv, std.string;
void main() {
int N = readln.chomp.to!int;
N.solve(0).writeln;
}
ulong solve(int n, int c) {
return n == 1 ? c : solve(n%2?n*3 + 1 : n/2, c+1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment