**HP Prime and Casio fx-CG 50: 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**

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;

**Casio fx-CG 50 ISLEAPYR**

“YEAR”? → Y

If Frac(Y ÷ 4) ≠ 0
Or (Frac(Y ÷ 100) = 0 And Frac(Y ÷ 400) ≠ 0)

Then

“No” ◢

Else

“YES” ◢

IfEnd

Eddie

This blog is
property of Edward Shore, 2017.

Nice!

ReplyDeleteWhich calculator do you recommend for programming on the go? I know there are much better options for that, I have a Surface Pro, a couple of portable Raspberry Pi mods... but I love calculators, what can I do! :D

Anyway I just want a really portable calculator with programming capabilities for doing really simple things.

I heard about the new Numworks but, as seen on the official Casio France YouTube channel, next September Casio will add a Python menu in the cg50, it looks promising.

Thanks and good website!!

Which is better?Casio FXCG50 or HP prime?

ReplyDeleteThis comment has been removed by the author.

ReplyDelete