Created
December 12, 2018 13:40
-
-
Save dlamblin/380086f79c5a90b4f5f54d5efcc25828 to your computer and use it in GitHub Desktop.
Print Powers of 2 to 2^64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use bignum; | |
$a=1; | |
for(0..64){ | |
printf "%2s%21s\n", $_, $a; | |
$a<<=1; | |
} | |
# (perl)$ perl -Mbignum -E '$a=1;for(0..64){say" "x($_<10).$_." "x(21-length($a)).$a;$a<<=1}' | |
# (perl)$ perl -Mbignum -E '$a=1;for(0..64){printf"%2s%21s\n",$_,$a;$a<<=1}' | |
# (bash)$ p=0 v=1;until [ $p -gt 64 ];do printf '%2s%21s\n' $((p++)) $v;((v<<=1));done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment