https://projecteuler.net/problem=19
よく考えると、月の日数は2月を除けば簡単に求められますね。
fn is_leap_year(y: Int) -> Bool: return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0) fn mdays(y: Int, m: Int) -> Int: if m == 2: return 29 if is_leap_year(y) else 28 else: return 30 + m * 9 // 8 % 2 fn f() -> Int: var counter = 0 var w = 1 for y in range(1900, 2001): for m in range(1, 13): if y >= 1901 and w == 0: counter += 1 w = (w + mdays(y, m)) % 7 return counter fn main(): print(f())