Post Reply 
Leap Year Test
10-13-2017, 01:36 AM
Post: #1
Leap Year Test
Introduction

The presented program tests whether a year is a leap year. A leap year has 366 days instead of 365, with the extra day given to February (February 29). The criteria for a leap year are:

* Leap years are year numbers evenly divisible by 4. Example: 1992, 2016
* Exception: years that are divisible by 100 but not divisible by 400. Example: 2000 is a leap year, but 1900 and 2100 aren’t.

HP Prime Program ISLEAPYEAR

Code:
EXPORT ISLEAPYEAR(y)
BEGIN
IF FP(y/4) ≠ 0 OR (FP(y/100) == 0 AND FP(y/400) ≠ 0)
THEN 
RETURN 0;
ELSE
RETURN 1;
END;
END;

Link to blog entry: http://edspi31415.blogspot.com/2017/10/h...-year.html
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Leap Year Test - Eddie W. Shore - 10-13-2017 01:36 AM
RE: Leap Year Test - Didier Lachieze - 10-13-2017, 03:06 AM
RE: Leap Year Test - chromos - 10-13-2017, 08:33 AM
RE: Leap Year Test - Didier Lachieze - 10-13-2017, 11:31 AM
RE: Leap Year Test - StephenG1CMZ - 10-13-2017, 06:37 PM
RE: Leap Year Test - chromos - 10-13-2017, 08:32 PM
RE: Leap Year Test - StephenG1CMZ - 10-13-2017, 10:35 PM
RE: Leap Year Test - David Hayden - 10-13-2017, 09:06 PM
RE: Leap Year Test - ggauny@live.fr - 10-14-2017, 09:33 AM
RE: Leap Year Test - StephenG1CMZ - 10-15-2017, 07:45 PM



User(s) browsing this thread: 1 Guest(s)