Dotfiles, utilities, and other apparatus.
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.

fizzbuzz.pl 470B

1234567891011121314151617181920
  1. #!/usr/bin/env perl
  2. # Write a program that prints the numbers from 1 to 100. But for multiples of
  3. # three print "Fizz" instead of the number and for the multiples of five print
  4. # "Buzz". For numbers which are multiples of both three and five print
  5. # "FizzBuzz".
  6. for (1..100) {
  7. my $no_number = 0;
  8. unless ($_ % 3) {
  9. print "Fizz";
  10. $no_number = 1;
  11. }
  12. unless ($_ % 5) {
  13. print "Buzz";
  14. $no_number = 1;
  15. }
  16. print $_ unless $no_number;
  17. print "\n";
  18. }