Skip to content

Instantly share code, notes, and snippets.

@Igneous
Created November 22, 2010 23:23
Show Gist options
  • Save Igneous/710920 to your computer and use it in GitHub Desktop.
Save Igneous/710920 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use 5.010;
$n=0;
$tally=0;
while ($n < 1000) {
#print "Number: $n, N-Mod-3: $nmod3, N-Mod-5: $nmod5\n";
if ($n % 3 == 0) {
$tally=$tally+$n;
}
if ($n % 5 == 0) {
$tally=$tally+$n;
}
if ($n % 5 == 0 && $n % 3 == 0) {
$tally=$tally-$n;
}
$n=$n+1;
}
print "$tally\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment