#!/usr/bin/perl # is Persian year y a leap year in the Persian calendar? sub is_leap_year { my $y = shift; my $a = ($y + 2345) % 2820; return 1 if $a == 2819; my $b = $a % 128; my $c; if ($b < 29) { $c = $b } else { $c = ($b - 29) % 33 } return 0 if $c == 0; return 1 if $c %4 == 0; return 0; } # Is Gregorian year g a leap year ** in the Persian calendar **? sub is_gregorian_leap_year { my $g = shift; return is_leap_year($g - 2008 + 1386); } my $prev; for (1979 .. 2028) { my $is = is_g_leap_year($_); printf "%4d %s\n", $_, $is ? "*" : " "; die if $is && $prev; $prev = $is; # $ct++ if $is; } #print ">> $ct\n";