Skip to content

Instantly share code, notes, and snippets.

@luelista
Created May 27, 2011 21:07
Show Gist options
  • Save luelista/996169 to your computer and use it in GitHub Desktop.
Save luelista/996169 to your computer and use it in GitHub Desktop.
perl one-liner for Collatz sequence
$ perl -e "$_=shift;while($_>1){if($_%2){$_*=3;$_++;}else{$_/=2;}print++$c,\"# $_\n\"}" 12345
# avec whitespace
$_=shift;
while($_>1){
if($_%2){
$_*=3;$_++;
}else{
$_/=2;
}
print++$c,"# $_\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment