Modo entrevista. Cronômetro de 5 min, sem dicas e sem autocompletar
Leap year
FácilBasics5 min
Write a function isLeapYear(year) that returns true if the year is a leap year and false if it is not.
- The parameter
yearis an integer from 1 to 9999. - A year is a leap year if it divides by 4 with no remainder:
2024is a leap year,2023is not. - Exception: a year that divides by 100 is a leap year only if it also divides by 400.
1900is not a leap year,2000is. - Return a boolean:
trueorfalse, not the string'true'.
Exemplos
isLeapYear(2024)Retorna true
isLeapYear(1900)Retorna false
isLeapYear(2000)Retorna true
Cobrada em Infosys · Fonte
Carregando o editor...
- Entrada
isLeapYear(2024)Esperadotrue - Entrada
isLeapYear(2023)Esperadofalse - Entrada
isLeapYear(1900)Esperadofalse - Entrada
isLeapYear(2000)Esperadotrue
Os testes ocultos rodam no envio