西暦が400で割り切れる年はうるう年である
400で割り切れない場合、西暦が100で割り切れる年はうるう年ではない
100で割り切れない場合、西暦が4で割り切れる年はうるう年である
4で割り切れない場合、うるう年ではない
much better to understand
ex if n % 400 != 0 && n % 100 = 0
return うるう年
n = 2000
-> 閏年
n = 1900
-> not 閏年
n = 2100
-> not 閏年
1900, 1, 1 Monday
1989, 7, 1
(364 + 365 * 88 + 22 + (31 + 28 + 31 + 30 + 31 + 30 + 1)) % 7 = 5
-> saturday
here is Java code
public class WhatDayWillItBe { public static void main(String[] args) { Day desiredDay = new Day(1983, 6, 18); Day referenceDay = new Day(1900, 1, 1); int referenceWeekDay = 1; int daysBetween = desiredDay.daysFrom(referenceDay): int uncorrectedWeekDay = referenceWeekDay + daysBetween; int weekday = uncorrectedWeekDay % 7; System.out.print("Weekday: "); System.out.println(weekday); } }