Curt Lundgren <[email protected]> Apr 13 08:04AM -0500

      I was inspired to write a short Perl script this morning:

      #! /usr/bin/perl -w
      use strict;
      use Time::Local;

      # Restrict years to the Unix epoch
      my $start_year = 1970;
      my $end_year = 2037;
      my $count = 0;

      my $year;
      my $month;
      my @mon = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );

      sub try_month {
      my $month = shift;
      my $year = shift() - 1900;
      my $time = timelocal( 0, 0, 1, 13, $month, $year );
      my @test = localtime( $time );
      # Is the 13th on a Friday?
      if( $test[6] == 5 ) {
      print "$mon[$month] ";
      $count++;
      }
      } # end try_month

      for( $year = $start_year; $year <= $end_year; $year++ ) {
      print "$year ";
      for( $month = 0; $month < 12; $month++ ) {
      try_month( $month, $year );
      }
      print "\n";
      }
      print "Total $count\n";

      Today is the second Friday the 13th of three that will occur this
      year.
      What I learned from running this script:

      - Every year has at least one Friday the 13th
      - Friday the 13th can occur in any month of the year
      - When there are three '13ths' in a year they either occur in
      February/March/November or January/April/July
      - Jan/Apr/Jul '13ths' only happen in a leap year and Feb/Mar/Nov only
      happen in non leap years

      Curt

Can I be impressed AND depressed by this at the same time?
--
Russ Crawford
615-506-4070

--
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nlug-talk?hl=en

Reply via email to