in which i have bad flashbacks to K-12 math classes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
523 B

  1. #!/usr/bin/perl
  2. =head1 NAME
  3. 1.pl
  4. =head1 SYNOPSIS
  5. perl ./1.pl
  6. =head1 DESCRIPTION
  7. Project Euler, Problem 1:
  8. If we list all the natural numbers below 10 that are multiples of 3 or 5, we
  9. get 3, 5, 6 and 9. The sum of these multiples is 23.
  10. Find the sum of all the multiples of 3 or 5 below 1000.
  11. =head1 AUTHOR
  12. Brennen Bearnes <bbearnes@gmail.com>
  13. http://p1k3.com/
  14. =cut
  15. use strict;
  16. use warnings;
  17. use 5.10.0;
  18. my $sum = 0;
  19. for (1..999) {
  20. my $yesh = ((!($_ % 3)) || (!($_ % 5)));
  21. $sum += $_ if $yesh;
  22. }
  23. say $sum;