Create a variable L, and assign the value of the year (2018) to it.
Create another variable NL, assign the value of the next leap year using variable L, and then print NL in R programming.
Answers
Answered by
17
x <- function(year){
year1 <- year + 205
for(i in year:year1){
if((i %% 4 == 0) & (i %% 100 != 0) | (i %% 400 == 0)){
print(i)
}
next
}
}
Answered by
0
Program is given below.
Explanation:
next_leap_year <- function(L)
{
NL <- L + 1:4
NL[(NL%%4==0&NL%%100!=0)|NL%%400==0]
}
next_leap_year(2018)
Refer the attached image for the output.
Attachments:
Similar questions