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
function oddDays ( N ) { var hund1 = N / 100 ; var hund4 = N / 400 ; var leap = N >> 2 ; var ord = N - leap ; if ( hund1 > 0 ) { ord += hund1 ; leap -= hund1 ; } if ( hund4 > 0 ) { ord -= hund4 ; leap += hund4 ; } var days = ord + leap * 2 ; var odd = days % 7 ; return odd ; } var N = 100 ; document . write ( oddDays ( N ) . toFixed ( ) ) ;