Leap year or Not



Problem to find the leap year or not.


Leap year comes from 4 years once.Example 4 , 8 , 12 , 16 , 20 , 24 (leap years).



Important Notes



  1. 100 , 200 , 300 is Not a leap year.
  2. But 400 , 800 , 1200 is a leap year.


Example-1:


Input    : n = 2004
Output   : Leap year   


Example-2:


Input    : n = 1900
Output   : Not a Leap year 







Solution




public class Main
{
    public static void main(String [] args)
    {
        int year = 2004;

        if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        {
            System.out.print("Leap year");
        }

        else
        {
            System.out.print("Not a Leap year");
        }
    }
}
n = 2004

if((n % 4 == 0 and n % 100 != 0) or n % 400 == 0):

    print("Leap year")

else:

    print("Not a Leap year")



Output



Leap year