Program to calculate the number of odd days in given number of years | Function to return the count of odd days ; Count of years divisible by 100 and 400 ; Every 4 th year is a leap year ; Every 100 th year is divisible by 4 but is not a leap year ; Every 400 th year is divisible by 100 but is a leap year ; Total number of extra days ; modulo ( 7 ) for final answer ; Number of days
< ? php function oddDays ( $ N ) { $ hund1 = floor ( $ N / 100 ) ; $ hund4 = floor ( $ N / 400 ) ; $ leap = $ N >> 2 ; $ ord = $ N - $ leap ; if ( $ hund1 ) { $ ord += $ hund1 ; $ leap -= $ hund1 ; } if ( $ hund4 ) { $ ord -= $ hund4 ; $ leap += $ hund4 ; } $ days = $ ord + $ leap * 2 ; $ odd = $ days % 7 ; return $ odd ; } $ N = 100 ; echo oddDays ( $ N ) ; ? >