Skip to content

Instantly share code, notes, and snippets.

@tony-o
Last active April 10, 2019 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony-o/0999977b7c5fa383733ac933031c988b to your computer and use it in GitHub Desktop.
Save tony-o/0999977b7c5fa383733ac933031c988b to your computer and use it in GitHub Desktop.
my @ARGV = do { sub eval { chomp &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) };
for (1..@ARGV[0]) {
my $i = $_;
while ($i != 1) {
last if $i == 0;
if (sprintf("%d", $i / 2) == $i / 2) {
$i /= 2;
next;
}
if (sprintf("%d", $i / 3) == $i / 3) {
$i /= 3;
next;
}
if (sprintf("%d", $i / 5) == $i / 5) {
$i /= 5;
next;
}
last;
}
my $is = '';
if ($i != 1) {
$is = ' not';
}
printf "%s is%s hamming\n", $_, $is;
}
# vim:syntax=perl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment