- & - > and
- | - > OR
- ! - > Not
-
> for(year in 2000:2018){
+ if (year%%4==0 & year%%100!=0 | year%%400==0){
+ result <- paste(year, "is a leap year.")
+ print(result)
+ }
+ else{
+ result <- paste(year, "is not a leap year.")
+ print(result)
+ }
+ }
[1] "2000 is a leap year."
[1] "2001 is not a leap year."
[1] "2002 is not a leap year."
[1] "2003 is not a leap year."
[1] "2004 is a leap year."
[1] "2005 is not a leap year."
[1] "2006 is not a leap year."
[1] "2007 is not a leap year."
[1] "2008 is a leap year."
[1] "2009 is not a leap year."
[1] "2010 is not a leap year."
[1] "2011 is not a leap year."
[1] "2012 is a leap year."
[1] "2013 is not a leap year."
[1] "2014 is not a leap year."
[1] "2015 is not a leap year."
[1] "2016 is a leap year."
[1] "2017 is not a leap year."
[1] "2018 is not a leap year."