// // Calculate months having 5 Fridays, // 5 Saturdays, and 5 Sundays // from year 1900 through 2100 // //================================================================= // DayOfTheWeek - returns day of the week (Gregorian only) // // on entry: month, day, year // on exit: result = index to days // (0 = Sat, 1 = Sun,... 5 = Thu, 6 = Fri) // local fn DayOfTheWeek (month as Int, day as Int, year as Int) as int Int result if month < 3 then month+=12: year-- result = (day + fix(((month + 1) * 13) / 5) + year ¬ + fix(year / 4) - fix(year / 100) + fix(year / 400)) % 7 end fn = result CFStringRef MonthNames(12) = {@"Greg Months",@"January",@"February",¬ @"March",@"April",@"May",@"June",@"July",¬ @"August",@"September",@"October",¬ @"November", @"December"} window 1,@"Five weekends" print Int x, mm, yyyy Int tot, none CFStringRef res for yyyy = 1900 to 2100 res = @"" for mm = 1 to 12 step 2 if mm == 9 then mm = 8 if fn DayOfTheWeek(mm,1,yyyy) == 6 res = concat (res,MonthNames(mm), @" ") tot++ end if next mm if len(res) < 1 then none++ if ((yyyy < 1906) && (len(res) > 1)) || ((yyyy > 2094) && (len(res) > 1)) print "Year ";yyyy;": ";: print res else if yyyy % 30 == 0 then print " ..." end if next yyyy print print "==========================" print "Total months with = " ;tot print "Total years without = ";none handleEvents