2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1 @@
10 DEF FNLY(Y)=(Y/4=INT(Y/4))*((Y/100<>INT(Y/100))+(Y/400=INT(Y/400)))

View file

@ -0,0 +1,33 @@
program-id. leap-yr.
*> Given a year, where 1601 <= year <= 9999
*> Determine if the year is a leap year
data division.
working-storage section.
1 input-year pic 9999.
1 binary.
2 int-date pic 9(8).
2 cal-mo-day pic 9(4).
procedure division.
display "Enter calendar year (1601 thru 9999): "
with no advancing
accept input-year
if input-year >= 1601 and <= 9999
then
*> if the 60th day of a year is Feb 29
*> then the year is a leap year
compute int-date = function integer-of-day
( input-year * 1000 + 60 )
compute cal-mo-day = function mod (
(function date-of-integer ( int-date )) 10000 )
display "Year " input-year space with no advancing
if cal-mo-day = 229
display "is a leap year"
else
display "is NOT a leap year"
end-if
else
display "Input date is not within range"
end-if
stop run
.
end program leap-yr.

View file

@ -1 +1 @@
=IF(OR(NOT(MOD(A1;400));AND(NOT(MOD(A1;4));MOD(A1;100)));"Leap Year";"Not a Leap Year")
=IF(OR(NOT(MOD(A1,400)),AND(NOT(MOD(A1,4)),MOD(A1,100))),"Leap Year","Not a Leap Year")

View file

@ -0,0 +1 @@
fun isLeapYear(year: Int) = year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)

View file

@ -0,0 +1,46 @@
BTW Determine if a Gregorian calendar year is leap
HAI 1.3
HOW IZ I Leap YR Year
BOTH SAEM 0 AN MOD OF Year AN 4
O RLY?
YA RLY
BOTH SAEM 0 AN MOD OF Year AN 100
O RLY?
YA RLY
BOTH SAEM 0 AN MOD OF Year AN 400
O RLY?
YA RLY
FOUND YR WIN
NO WAI
FOUND YR FAIL
OIC
NO WAI
FOUND YR WIN
OIC
NO WAI
FOUND YR FAIL
OIC
IF U SAY SO
I HAS A Yearz ITZ A BUKKIT
Yearz HAS A SRS 0 ITZ 1900
Yearz HAS A SRS 1 ITZ 1904
Yearz HAS A SRS 2 ITZ 1994
Yearz HAS A SRS 3 ITZ 1996
Yearz HAS A SRS 4 ITZ 1997
Yearz HAS A SRS 5 ITZ 2000
IM IN YR Loop UPPIN YR Index WILE DIFFRINT Index AN 6
I HAS A Yr ITZ Yearz'Z SRS Index
I HAS A Not
I IZ Leap YR Yr MKAY
O RLY?
YA RLY
Not R ""
NO WAI
Not R " NOT"
OIC
VISIBLE Yr " is" Not " a leap year"
IM OUTTA YR Loop
KTHXBYE

View file

@ -0,0 +1,7 @@
isLeapYear := proc(year)
if not year mod 4 = 0 or (year mod 100 = 0 and not year mod 400 = 0) then
return false;
else
return true;
end if;
end proc:

View file

@ -1 +1 @@
isLeapYear[y_]:= y~Mod~4 == 0 && (y~Mod~100 != 0 || y~Mod~400 == 0)
LeapYearQ[2002]

View file

@ -0,0 +1,17 @@
program LeapYear;
uses
sysutils;//includes isLeapYear
procedure TestYear(y: word);
begin
if IsLeapYear(y) then
writeln(y,' is a leap year')
else
writeln(y,' is NO leap year');
end;
Begin
TestYear(1900);
TestYear(2000);
TestYear(2100);
TestYear(1904);
end.

View file

@ -1,12 +1,2 @@
function isLeapYear ($year)
{
If (([System.Int32]::TryParse($year, [ref]0)) -and ($year -le 9999))
{
$bool = [datetime]::isleapyear($year)
}
else
{
throw "Year format invalid. Use only numbers up to 9999."
}
return $bool
}
$Year = 2016
[System.DateTime]::IsLeapYear( $Year )

View file

@ -0,0 +1,3 @@
require 'date'
Date.leap?(year)

View file

@ -1,7 +1,5 @@
fn is_leap(year: i32) -> bool {
if year % 100 == 0 {
year % 400 == 0
} else {
year % 4 == 0
let factor = |x| year % x == 0;
factor(4) && (!factor(100) || factor(400))
}
}