Long year: Difference between revisions

19,121 bytes added ,  3 months ago
Added Easylang
(→‎{{header|Snobol}}: simplify loop logic)
(Added Easylang)
 
(33 intermediate revisions by 14 users not shown)
Line 10:
{{trans|C++}}
 
<langsyntaxhighlight lang="11l">F is_long_year(year)
F p(year)
R (year + (year I/ 4) - (year I/ 100) + (year I/ 400)) % 7
Line 17:
L(year) 2000..2100
I is_long_year(year)
print(year, end' ‘ ’)</langsyntaxhighlight>
 
{{out}}
Line 25:
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">BYTE FUNC P(CARD y)
RETURN ((y+(y/4)-(y/100)+(y/400)) MOD 7)
 
Line 50:
 
LMARGIN=oldLMARGIN ;restore left margin on the screen
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Long_year.png Screenshot from Atari 8-bit computer]
Line 64:
=={{header|Ada}}==
The Ada calendar package handles dates for years 1901 through 2399. This program outputs all the long years within that range.
<langsyntaxhighlight Adalang="ada">-------------------------------------------------------------
-- Calculate long years
-- Reference: https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
Line 98:
end loop;
end Main;
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 114:
=={{header|ALGOL 68}}==
{{Trans|ALGOL W}}
<langsyntaxhighlight lang="algol68">BEGIN # find "long years" - years which have 53 weeks this is equivalent to #
# finding years where 1st Jan or 31st Dec are Thursdays #
# returns the day of the week of the specified date (d/m/y), Sunday = 1 #
Line 137:
IF is long year( year ) THEN print( ( " ", whole( year, 0 ) ) ) FI
OD
END</langsyntaxhighlight>
{{out}}
<pre>
Line 145:
=={{header|ALGOL-M}}==
 
<langsyntaxhighlight ALGOLlang="algol">BEGIN
 
COMMENT
Line 202:
 
END
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 211:
=={{header|ALGOL W}}==
Uses the Day_of_week procedure from the Day_of_the_week task.
<langsyntaxhighlight lang="algolw">begin % find "long years" - years which have 53 weeks %
% this is equivalent to finding years where %
% 1st Jan or 31st Dec are Thursdays %
Line 236:
if isLongYear( year ) then writeon( I_W := 5, S_W := 0, year )
end for_year
end.</langsyntaxhighlight>
{{out}}
<pre>
long years 2000-2099: 2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099
</pre>
 
=={{header|Amazing Hopper}}==
Task solves with Amazing Hopper flavour Basico:
<syntaxhighlight lang="c">
 
#include <basico.h>
 
#proto esañolargo(_X_)
 
algoritmo
 
año=1800, c=5
imprimir ("Long (53 week) years between 1800 and 2100:\n\n" )
iterar grupo ( ++año, #( año<=2100 ), \
cuando ( #( es año largo( año )==4 || es año largo( año-1 )==3 ) ){ \
imprimir ( año, " ", solo si( #( c==0 ) , NL; c=6 ), --c ) } )
terminar
 
subrutinas
 
es año largo (y)
retornar ' #( (y + floor(y / 4) - floor(y / 100) + floor(y / 400)) % 7 ) '
</syntaxhighlight>
{{out}}
<pre>
Long (53 week) years between 1800 and 2100:
 
1801 1807 1812 1818 1824 1829
1835 1840 1846 1852 1857 1863
1868 1874 1880 1885 1891 1896
1903 1908 1914 1920 1925 1931
1936 1942 1948 1953 1959 1964
1970 1976 1981 1987 1992 1998
2004 2009 2015 2020 2026 2032
2037 2043 2048 2054 2060 2065
2071 2076 2082 2088 2093 2099
</pre>
 
=={{header|APL}}==
<langsyntaxhighlight lang="apl">dec31wddec31weekday ← {7|(⍵+⌊(⍵÷4)+⌊(⍵÷400)-⌊⍵÷100)}
longisolongyear ← {(4 = dec31wddec31weekday ⍵) ∨ (3 = dec31wddec31weekday (⍵ - 1))}</langsyntaxhighlight>
 
{{Out}}
<pre> (long y){⍵/y←1800⍨isolongyear ⍵}1800+⍳300
1801 1807 1812 1818 1824 1829 1835 1840 1846 1852 1857 1863 1868 1874 1880 1885
1891 1896 1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959 1964
Line 255 ⟶ 295:
=={{header|AppleScript}}==
 
<langsyntaxhighlight lang="applescript">on isLongYear(y)
-- ISO8601 weeks begin on Mondays and belong to the year in which they have the most days.
-- A year which begins on a Thursday, or which begins on a Wednesday and is a leap year,
Line 272 ⟶ 312:
end repeat
 
return longYears</langsyntaxhighlight>
 
{{output}}
Line 279 ⟶ 319:
On the other hand, since the cycle repeats every 400 years, it's possible to cheat with a precalculated look-up list:
 
<langsyntaxhighlight lang="applescript">on isLongYear(y)
return (y mod 400 is in {4, 9, 15, 20, 26, 32, 37, 43, 48, 54, 60, 65, 71, 76, 82, 88, 93, 99, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325, 331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398})
end isLongYear
Line 288 ⟶ 328:
end repeat
 
return longYears</langsyntaxhighlight>
 
=={{header|Arturo}}==
Line 294 ⟶ 334:
{{trans|Nim}}
 
<langsyntaxhighlight lang="rebol">longYear?: function [year][
date: to :date .format: "dd/MM/yyyy" ~"01/01/|year|"
 
Line 303 ⟶ 343:
 
print "Years with 53 weeks between 2000 and 2100:"
print select 2000..2100 => longYear?</langsyntaxhighlight>
 
{{out}}
Line 311 ⟶ 351:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">Long_year(y) {
A := Mod(y + floor(y/4) - floor(y/100) + floor(y/400), 7)
y--, B := Mod(y + floor(y/4) - floor(y/100) + floor(y/400), 7)
return A=4 || B=3
}</langsyntaxhighlight>
Examples:<langsyntaxhighlight AutoHotkeylang="autohotkey">loop, 100{
y := 1999+A_Index
res .= Long_year(y) ? Y " ": ""
}
MsgBox % "Long Years 2000-2100 : " res
return</langsyntaxhighlight>
{{out}}
<pre>Long Years 2000-2100 : 2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099 </pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f LONG_YEAR.AWK
BEGIN {
Line 358 ⟶ 398:
return(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 369 ⟶ 409:
 
 
=={{header|BASIC256BASIC}}==
 
<lang BASIC256>function p(y)
==={{header|Applesoft BASIC}}===
{{trans|Commodore BASIC}}
<syntaxhighlight lang="gwbasic"> 10 DEF FN M7(N) = N - 7 * INT (N / 7)
20 DEF FN WD(Y) = FN M7(Y + INT (Y / 4) - INT (Y / 100) + INT (Y / 400))
30 DEF FN LY(Y) = (4 = FN WD(Y)) OR (3 = FN WD(Y - 1))
40 HOME : INVERSE : PRINT "**** LIST OF ISO LONG YEARS ****": NORMAL
50 INPUT "START YEAR? ";S
60 INPUT "END YEAR? ";E
70 PRINT : FOR Y = S TO E
80 IF FN LY(Y) THEN PRINT S$Y;:S$ = " "
90 NEXT Y</syntaxhighlight>
==={{header|ASIC}}===
{{trans|Commodore BASIC}}
<syntaxhighlight lang="basic">
REM Long year
CLS
PRINT "**** List of ISO long years ****"
PRINT "Start year";
INPUT S
PRINT "End year";
INPUT E
PRINT
FOR Y = S TO E
GOSUB CALCLY:
IF LY <> 0 THEN
PRINT Y;
ENDIF
NEXT Y
PRINT
END
 
CALCLY:
REM Nonzero if Y is long
LY = 0
AY = Y
GOSUB CALCWD:
IF WD = 4 THEN
LY = -1
ENDIF
AY = Y - 1
GOSUB CALCWD:
IF WD = 3 THEN
LY = -1
ENDIF
RETURN
 
CALCWD:
REM Weekday of AY-12-31, 0 = Sunday
WD = AY
TMP = AY / 4
WD = WD + TMP
TMP = AY / 100
WD = WD - TMP
TMP = AY / 400
WD = WD + TMP
WD = WD MOD 7
RETURN
</syntaxhighlight>
{{out}}
<pre>
**** List of ISO long years ****
Start year?1995
End year?2045
 
1998 2004 2009 2015 2020 2026 2032 2037 2043
</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">function p(y)
return (y + int(y/4) - int(y/100) + int(y/400)) mod 7
end function
Line 381 ⟶ 490:
if isLongYear(y) then print y
next y
end</langsyntaxhighlight>
{{out}}
<pre>2004
Line 402 ⟶ 511:
2099</pre>
 
==={{header|BBC BASIC}}===
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$ + "DATELIB"
 
REM The function as per specification.
Line 424 ⟶ 532:
NEXT
PRINT
ENDPROC</langsyntaxhighlight>
{{out}}
<pre>
Line 431 ⟶ 539:
The long years between 2100 and 2200 are 2105 2111 2116 2122 2128 2133 2139 2144 2150 2156 2161 2167 2172 2178 2184 2189 2195
</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{trans| Commodore BASIC}}
<syntaxhighlight lang="qbasic">10 cls
20 rem WD(Y) = WEEKDAY OF Y-12-31, 0 = SUNDAY
30 def fnwd(Y) = (Y + INT(Y / 4) - INT(Y / 100) + INT(Y / 400)) mod 7
40 rem LY(Y) = NONZERO IF Y IS LONG
50 def fnly(Y) = (4 = FNWD(Y)) OR (3 = FNWD(Y-1))
60 print "**** LIST OF ISO LONG YEARS ****"
70 input "START YEAR? ",s
80 input "END YEAR? ",e
90 print
100 for y = s to e
110 if fn ly(y) then print y,
120 next y
130 print
140 end</syntaxhighlight>
{{out}}
<pre>Similar as Commodore BASIC entry.</pre>
 
==={{header|Commodore BASIC}}===
<syntaxhighlight lang="basic">100 REM M7(N) = N MOD 7
110 DEF FNM7(N) = N - 7*INT(N / 7)
120 :
130 REM WD(Y) = WEEKDAY OF Y-12-31, 0 = SUNDAY
140 DEF FNWD(Y) = FNM7(Y + INT(Y / 4) - INT(Y / 100) + INT(Y / 400))
150 :
160 REM LY(Y) = NONZERO IF Y IS LONG
170 DEF FNLY(Y) = (4 = FNWD(Y)) OR (3 = FNWD(Y-1))
180 :
190 PRINT CHR$(147); CHR$(18); "**** LIST OF ISO LONG YEARS ****"
200 INPUT "START YEAR"; S
210 INPUT "END YEAR"; E
220 PRINT
230 :
240 FOR Y = S TO E
250 : IF FNLY(Y) THEN PRINT Y,
260 NEXT Y
270 PRINT</syntaxhighlight>
 
{{Out}}
<pre>**** LIST OF ISO LONG YEARS ****
 
START YEAR? 1995
END YEAR? 2045
 
1998 2004 2009 2015
2020 2026 2032 2037
2043
 
READY.</pre>
 
==={{Header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">function p(y as unsigned integer) as unsigned integer
return ( y + int(y/4) - int(y/100) + int(y/400) ) mod 7
end function
 
function islongyear( y as uinteger ) as boolean
if p(y) = 4 then return true
if p(y-1) = 3 then return true
return false
end function
 
print islongyear(1998)
print islongyear(2020)
print islongyear(2021)</syntaxhighlight>
{{out}}
<pre>
true
true
false
</pre>
 
==={{header|Gambas}}===
{{trans|BASIC256}}
<syntaxhighlight lang="vbnet">Public Sub Main()
For y As Integer = 2000 To 2100
If isLongYear(y) Then Print y,
Next
End
 
Function p(y As Integer) As Integer
Return (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7
End Function
 
Function isLongYear(y As Integer) As Boolean
If p(y) = 4 Then Return True
If p(y - 1) = 3 Then Return True
Return False
End Function</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
==={{header|GW-BASIC}}===
<syntaxhighlight lang="gwbasic">10 INPUT "Enter a year: ", Y
20 X = Y
30 GOSUB 100
40 IF P = 4 THEN L = 1
50 X = Y - 1
60 GOSUB 100
70 IF P = 3 THEN L = 1
80 IF L = 1 THEN PRINT Y; " is a long year." ELSE PRINT Y;" is not a long year."
90 END
100 P = X + INT(X/4) - INT(X/100) + INT(X/400)
110 P = P MOD 7
120 RETURN</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 PROGRAM "Longyear.bas"
110 DEF RD(Y)=Y*365+INT(Y/4)-INT(Y/100)+INT(Y/400)
120 DEF LONGYEAR(Y)=(4=MOD(RD(Y),7)) OR(4=MOD((RD(Y-1)+1),7))
130 INPUT PROMPT "Start year: ":S
140 INPUT PROMPT "End year: ":E
150 FOR Y=S TO E
160 IF LONGYEAR(Y) THEN PRINT Y,
170 NEXT
180 PRINT</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{trans| Commodore BASIC}}
<syntaxhighlight lang="qbasic">10 CLS
20 REM WD(Y) = WEEKDAY OF Y-12-31, 0 = SUNDAY
30 DEF FNWD(Y) = (Y + INT(Y/4) - INT(Y/100) + INT(Y/400)) MOD 7
40 REM LY(Y) = NONZERO IF Y IS LONG
50 DEF FNLY(Y) = (4 = FNWD(Y)) OR (3 = FNWD(Y-1))
60 PRINT "*** LIST OF ISO LONG YEARS ***"
70 INPUT "START YEAR ";S
80 INPUT " END YEAR ";E
90 PRINT
100 FOR Y = S TO E
110 IF FNLY(Y) THEN PRINT Y,
120 NEXT Y
130 PRINT
140 END</syntaxhighlight>
{{out}}
<pre>Similar as Commodore BASIC entry.</pre>
 
==={{header|Nascom BASIC}}===
{{trans|Commodore BASIC}}
{{works with|Nascom ROM BASIC|4.7}}
<syntaxhighlight lang="basic">
10 REM Long year
20 REM FNM7(N)=MOD(N,7)
30 DEF FNM7(N)=N-7*INT(N/7)
40 REM FNWD(Y)=Weekday of Y-12-31, 0 Sunday
50 DEF FND(Y)=Y+INT(Y/4)-INT(Y/100)+INT(Y/400)
60 DEF FNWD(Y)=FNM7(FND(Y))
70 REM FNLY(Y)=Nonzero if Y is long
80 DEF FNLY(Y)=(4=FNWD(Y))OR(3=FNWD(Y-1))
90 CLS
100 PRINT "**** ";
110 PRINT "List of ISO long years";
120 PRINT " ****"
130 INPUT "Start year";S
140 INPUT "End year";E
150 PRINT
160 FOR Y=S TO E
170 IF FNLY(Y) THEN PRINT Y;
180 NEXT Y
190 PRINT
200 END
</syntaxhighlight>
{{out}}
<pre>
**** List of ISO long years ****
Start year? 1995
End year? 2045
 
1998 2004 2009 2015 2020 2026 2032 2037 2043
</pre>
 
==={{header|Palo Alto Tiny BASIC}}===
{{trans|Commodore BASIC}}
<syntaxhighlight lang="basic">
10 REM LONG YEAR
20 PRINT "*** LIST OF ISO LONG YEARS ***"
30 INPUT "START YEAR"B
40 INPUT "END YEAR"E
50 FOR Y=B TO E
60 GOSUB 200
70 IF L#0 PRINT Y," ",
80 NEXT Y
90 PRINT
100 STOP
190 REM L NONZERO IF Y IS LONG
200 LET L=0,J=Y
210 GOSUB 400
220 IF W=4 LET L=1
230 LET J=Y-1
240 GOSUB 400
250 IF W=3 LET L=1
260 RETURN
370 REM CALCULATE DAY OF WEEK W GIVEN
380 REM OF J-12-31, GIVEN YEAR J
390 REM SUNDAY = 0, SATURDAY = 6
400 LET W=J+J/4-J/100+J/400
410 LET W=W-(W/7)*7
420 RETURN
</syntaxhighlight>
{{out}}
<pre>
*** LIST OF ISO LONG YEARS ***
START YEAR:1995
END YEAR:2045
1998 2004 2009 2015 2020 2026 2032 2037 2043
</pre>
 
==={{header|PureBasic}}===
{{trans|BASIC256}}
<syntaxhighlight lang="purebasic">Procedure.b p(y)
ProcedureReturn (y + Int(y/4) - Int(y/100) + Int(y/400)) % 7
EndProcedure
 
Procedure.b isLongYear(y)
ProcedureReturn Bool((p(y) = 4) Or (p(y - 1) = 3))
EndProcedure
 
If OpenConsole()
For y = 2000 To 2100
If isLongYear(y)
PrintN(Str(y))
EndIf
Next y
Print(""): Input()
CloseConsole()
EndIf</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
==={{header|QuickBASIC}}===
{{Works with|QB|4.x}}
{{Works with|PDS|7.x}}
{{Works with|QBasic|1.x}}
{{Works with|VB-DOS|1.0}}
Translated from Delphi
<syntaxhighlight lang="vb">
DEFINT A-Z
 
DECLARE FUNCTION p% (Yr AS INTEGER)
DECLARE FUNCTION LongYear% (Yr AS INTEGER)
 
DIM iYi, iYf, i
 
CLS
PRINT "This program calculates which are 53-week years in a range."
PRINT
INPUT "Initial year"; iYi
INPUT "Final year (could be the same)"; iYf
IF iYf >= iYi THEN
FOR i = iYi TO iYf
IF LongYear(i) THEN
PRINT i; " ";
END IF
NEXT i
END IF
PRINT
PRINT
PRINT "End of program."
END
 
FUNCTION LongYear% (Yr AS INTEGER)
LongYear% = (p%(Yr) = 4) OR (p%(Yr - 1) = 3)
END FUNCTION
 
FUNCTION p% (Yr AS INTEGER)
p% = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
</syntaxhighlight>
{{Out}}
<pre>
This program calculates which are 53-week years in a range.
 
Initial year? 1900
Final year (can be the same)? 1999
1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959
1964 1970 1976 1981 1987 1992 1998
 
End of program.
</pre>
 
==={{header|Run BASIC}}===
{{trans|BASIC256}}
<syntaxhighlight lang="vb">function p(y)
p = (y + int(y/4) - int(y/100) + int(y/400)) mod 7
end function
 
function isLongYear(y)
isLongYear = (p(y) = 4) or (p(y -1) = 3)
end function
 
for y = 2000 to 2100
if isLongYear(y) then print y
next y
end</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
==={{header|S-BASIC}}===
<syntaxhighlight lang="basic">
$lines
 
rem - compute p mod q
function mod(p, q = integer) = integer
end = p - q * (p/q)
 
comment
return day of week (Sun = 0, Mon = 1, etc.) for a
given Gregorian calendar date using Zeller's congruence
end
function dayofweek (mo, da, yr = integer) = integer
var y, c, z = integer
if mo < 3 then
begin
mo = mo + 10
yr = yr - 1
end
else mo = mo - 2
y = mod(yr,100)
c = int(yr / 100)
z = int((26 * mo - 2) / 10)
z = z + da + y + int(y/4) + int(c/4) - 2 * c + 777
z = mod(z,7)
end = z
 
comment
The simplest of several possible tests is that
any ISO year starting or ending on a
Thursday is "long", i.e., spans 53 weeks
end
function islongyear(yr = integer) = integer
var thursday, result = integer
thursday = 4
if (dayofweek(1,1,yr) = thursday) or \
(dayofweek(12,31,yr) = thursday) then
result = -1 rem "true"
else
result = 0 rem "false"
end = result
 
rem - main program begins here
 
var year = integer
print "ISO years that will be long in this century:"
for year = 2000 to 2099
if islongyear(year) then print year;
next year
 
end</syntaxhighlight>
{{output}}
<pre>
ISO years that will be long in this century:
2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088
2093 2099
</pre>
 
==={{header|Tiny BASIC}}===
<syntaxhighlight lang="tiny basic"> PRINT "What year would you like?"
INPUT Y
LET X = Y
GOSUB 100
IF P = 4 THEN LET L = 1
LET X = Y - 1
GOSUB 100
IF P = 3 THEN LET L = 1
IF L = 1 THEN PRINT Y," is a long year."
IF L = 0 THEN PRINT Y," is not a long year."
END
100 LET P = X + X/4 - X/100 + X/400
110 IF P < 7 THEN RETURN
LET P = P - 7
GOTO 110
</syntaxhighlight>
{{out}}
<pre>
What year would you like?
2020
2020 is a long year.
 
What year would you like?
2021
2021 is not a long year.
</pre>
 
==={{header|True BASIC}}===
{{trans|BASIC256}}
<syntaxhighlight lang="qbasic">FUNCTION p(y) = REMAINDER((y + INT(y/4) - INT(y/100) + INT(y/400)), 7)
 
FUNCTION isLongYear(y)
IF p(y) = 4 THEN
LET isLongYear = 1
ELSEIF p(y-1) = 3 THEN
LET isLongYear = 1
ELSE
LET isLongYear = 0
END IF
END FUNCTION
 
FOR y = 2000 TO 2100
IF isLongYear(y) > 0 THEN PRINT y
NEXT y
END</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
==={{header|Visual Basic}}===
{{works with|Visual Basic|5}}
{{works with|Visual Basic|6}}
{{works with|VBA|Access 97}}
{{works with|VBA|6.5}}
{{works with|VBA|7.1}}
<syntaxhighlight lang="vb">Option Explicit
 
Function IsLongYear(ByVal Year As Integer) As Boolean
Select Case vbThursday
Case VBA.DatePart("w", VBA.DateSerial(Year, 1, 1)), _
VBA.DatePart("w", VBA.DateSerial(Year, 12, 31))
IsLongYear = True
End Select
End Function
 
Sub Main()
'test
Dim l As Long
For l = 1990 To 2021
Select Case l
Case 1992, 1998, 2004, 2009, 2015, 2020
Debug.Assert IsLongYear(l)
Case Else
Debug.Assert Not IsLongYear(l)
End Select
Next l
End Sub
</syntaxhighlight>
 
===={{header|Visual Basic for DOS}}====
{{trans|Delphi}}
<syntaxhighlight lang="vb">OPTION EXPLICIT
 
DECLARE FUNCTION p (Yr AS INTEGER) AS INTEGER
DECLARE FUNCTION LongYear (Yr AS INTEGER) AS INTEGER
 
DIM iYi AS INTEGER, iYf AS INTEGER, i AS INTEGER
 
CLS
PRINT "This program calculates which are 53-week years in a range."
PRINT
INPUT "Initial year"; iYi
INPUT "Final year (could be the same)"; iYf
IF iYf >= iYi THEN
FOR i = iYi TO iYf
IF LongYear(i) THEN
PRINT i; " ";
END IF
NEXT i
END IF
PRINT
PRINT
PRINT "End of program."
END
 
FUNCTION p (Yr AS INTEGER) AS INTEGER
p = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
 
FUNCTION LongYear (Yr AS INTEGER) AS INTEGER
LongYear = (p(Yr) = 4) OR (p(Yr - 1) = 3)
END FUNCTION
</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
{{trans|BASIC256}}
<syntaxhighlight lang="qbasic">PROGRAM "LongYear"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
DECLARE FUNCTION p (y)
DECLARE FUNCTION isLongYear (y)
 
FUNCTION Entry ()
FOR y = 2000 TO 2100
IF isLongYear(y) THEN PRINT y,
NEXT y
END FUNCTION
 
FUNCTION p (y)
RETURN (y + INT(y/4) - INT(y/100) + INT(y/400)) MOD 7
END FUNCTION
 
FUNCTION isLongYear (y)
RETURN (p(y) = 4) OR (p(y - 1) = 3)
END FUNCTION
END PROGRAM</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
==={{header|Yabasic}}===
{{trans|BASIC256}}
<syntaxhighlight lang="yabasic">sub p(y)
return mod((y + int(y/4) - int(y/100) + int(y/400)), 7)
end sub
 
sub isLongYear(y)
return (p(y) = 4) or (p(y - 1) = 3)
end sub
 
for y = 2000 to 2100
if isLongYear(y) print y
next y
end</syntaxhighlight>
{{out}}
<pre>Same as BASIC256 entry.</pre>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let p(y) = (y + y/4 - y/100 + y/400) rem 7
Line 440 ⟶ 1,068:
let start() be
for y = 2000 to 2100
if longyear(y) do writef("%N*N", y)</langsyntaxhighlight>
{{out}}
<pre>2004
Line 462 ⟶ 1,090:
 
=={{header|C sharp}}==
<langsyntaxhighlight lang="csharp">using static System.Console;
using System.Collections.Generic;
using System.Linq;
Line 479 ⟶ 1,107:
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 486 ⟶ 1,114:
 
=={{header|C}}==
<langsyntaxhighlight lang="cpp">#include <stdio.h>
#include <math.h>
 
Line 513 ⟶ 1,141:
printf("\n");
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 524 ⟶ 1,152:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">// Reference:
// https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
 
Line 553 ⟶ 1,181:
std::cout << '\n';
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 567 ⟶ 1,195:
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(defn long-year? [year]
(-> (java.time.LocalDate/of year 12 28)
(.get (.weekOfYear (java.time.temporal.WeekFields/ISO)))
(= 53)))
 
(filter long-year? (range 2000 2100))</langsyntaxhighlight>
{{out}}
<pre>
Line 578 ⟶ 1,206:
</pre>
 
=={{header|Commodore BASICCLU}}==
<syntaxhighlight lang="clu">% We can't hide one procedure inside another, but
<lang basic>100 REM M7(N) = N MOD 7
% we can hide the helper `p' in a cluster
110 DEF FNM7(N) = N - 7*INT(N / 7)
120 :
130 REM WD(Y) = WEEKDAY OF Y-12-31, 0 = SUNDAY
140 DEF FNWD(Y) = FNM7(Y + INT(Y / 4) - INT(Y / 100) + INT(Y / 400))
150 :
160 REM LY(Y) = NONZERO IF Y IS LONG
170 DEF FNLY(Y) = (4 = FNWD(Y)) OR (3 = FNWD(Y-1))
180 :
190 PRINT CHR$(147); CHR$(18); "**** LIST OF ISO LONG YEARS ****"
200 INPUT "START YEAR"; S
210 INPUT "END YEAR"; E
220 PRINT
230 :
240 FOR Y = S TO E
250 : IF FNLY(Y) THEN PRINT Y,
260 NEXT Y
270 PRINT</lang>
 
longyear = cluster is test
{{Out}}
rep = null
<pre>**** LIST OF ISO LONG YEARS ****
p = proc (n: int) returns (int)
return ((n + n/4 - n/100 + n/400) // 7)
end p
 
test = proc (y: int) returns (bool)
START YEAR? 1995
return (p(y)=4 | p(y-1)=3)
END YEAR? 2045
end test
end longyear
 
start_up = proc ()
1998 2004 2009 2015
po: stream := stream$primary_output()
2020 2026 2032 2037
2043
for i: int in int$from_to(2000, 2100) do
if longyear$test(i) then
stream$putl(po, int$unparse(i))
end
end
end start_up</syntaxhighlight>
{{out}}
<pre>2004
2009
2015
2020
2026
2032
2037
2043
2048
2054
2060
2065
2071
2076
2082
2088
2093
2099</pre>
 
READY.</pre>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(defun december-31-weekday (year)
(mod (+ year (floor year 4) (- (floor year 100)) (floor year 400)) 7))
 
Line 618 ⟶ 1,260:
 
(format t "Long years between 1800 and 2100:~&~a~%"
(loop for y from 1800 to 2100 if (iso-long-year-p y) collect y))</langsyntaxhighlight>
 
{{Out}}
Line 626 ⟶ 1,268:
1970 1976 1981 1987 1992 1998 2004 2009 2015 2020 2026 2032 2037 2043 2048
2054 2060 2065 2071 2076 2082 2088 2093 2099)</pre>
 
=={{header|Cowgol}}==
<syntaxhighlight lang="cowgol">include "cowgol.coh";
 
sub longyear(year: uint16): (r: uint8) is
sub p(y: uint16): (d: uint8) is
d := ((y + y/4 - y/100 + y/400) % 7) as uint8;
end sub;
 
r := 0;
if p(year) == 4 or p(year-1) == 3 then
r := 1;
end if;
end sub;
 
var year: uint16 := 2000;
while year <= 2100 loop
if longyear(year) != 0 then
print_i16(year);
print_nl();
end if;
year := year + 1;
end loop;</syntaxhighlight>
{{out}}
<pre>2004
2009
2015
2020
2026
2032
2037
2043
2048
2054
2060
2065
2071
2076
2082
2088
2093
2099</pre>
 
=={{header|Dc}}==
{{trans|Tcl}}
{{works with|GNU dc|1.3.95}}
<langsyntaxhighlight lang="dc">[0q]s0
[1q]s1
[1r- r 1r- * 1r-]sO # O = logical OR
Line 684 ⟶ 1,368:
[Long years between 1800 and 2100:]P AP
1800 2100 lDx
AP</langsyntaxhighlight>
 
{{out}}
Line 700 ⟶ 1,384:
Note: The Library '''System.DateUtils''' implement a '''WeeksInYear''',but not working, return 52 always.
{{Trans|C++}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Long_year;
 
Line 743 ⟶ 1,427:
Readln;
end.
</syntaxhighlight>
</lang>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc p(word y) word:
(y + y/4 - y/100 + y/400) % 7
corp
 
proc longyear(word y) bool:
p(y) = 4 or p(y-1) = 3
corp
 
proc main() void:
word y;
for y from 2000 upto 2100 do
if longyear(y) then writeln(y) fi
od
corp</syntaxhighlight>
{{out}}
<pre>2004
2009
2015
2020
2026
2032
2037
2043
2048
2054
2060
2065
2071
2076
2082
2088
2093
2099</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
func p y .
return (y + y div 4 - y div 100 + y div 400) mod 7
.
func longyear y .
return if p y = 4 or p (y - 1) = 3
.
for y = 2000 to 2100
if longyear y = 1
write y & " "
.
.
</syntaxhighlight>
 
{{out}}
<pre>
2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099
</pre>
 
=={{header|Elixir}}==
<langsyntaxhighlight lang="elixir">defmodule ISO do
def long_year?(y) do
{:ok, jan1} = Date.new(y,1,1)
Line 754 ⟶ 1,493:
end
 
IO.inspect(Enum.filter(1990..2050, &ISO.long_year?/1))</langsyntaxhighlight>
 
{{Out}}
Line 761 ⟶ 1,500:
=={{header|Factor}}==
{{works with|Factor|0.99 2019-10-06}}
<langsyntaxhighlight lang="factor">USING: calendar formatting io kernel math.ranges sequences ;
 
: long-year? ( n -- ? ) 12 28 <date> week-number 53 = ;
 
"Year Long?\n-----------" print 1990 2021 [a,b]
[ dup long-year? "yes" "no" ? "%d %s\n" printf ] each</langsyntaxhighlight>
{{out}}
<pre style="height:45ex">
Line 806 ⟶ 1,545:
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">: dec31wd ( year -- weekday ) dup dup 4 / swap dup 100 / swap 400 / swap - + + 7 mod ;
: long? ( year -- flag ) dup dec31wd 4 = if drop 1 else 1 - dec31wd 3 = if 1 else 0 then then ;
: demo ( startyear endyear -- ) cr swap do i long? if i . then loop cr ;</langsyntaxhighlight>
 
{{Out}}
Line 816 ⟶ 1,555:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran">
program longyear
use iso_fortran_env, only: output_unit, input_unit
Line 854 ⟶ 1,593:
end function is_long_year
end program longyear
</syntaxhighlight>
</lang>
 
{{out}}
Line 868 ⟶ 1,607:
2026 2032 2037 2043 2048 2054 2060 2065 2071 2076
2082 2088 2093 2099 %
</pre>
 
=={{Header|FreeBASIC}}==
<lang freebasic>function p(y as unsigned integer) as unsigned integer
return ( y + int(y/4) - int(y/100) + int(y/400) ) mod 7
end function
 
function islongyear( y as uinteger ) as boolean
if p(y) = 4 then return true
if p(y-1) = 3 then return true
return false
end function
 
print islongyear(1998)
print islongyear(2020)
print islongyear(2021)</lang>
{{out}}
<pre>
true
true
false
</pre>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 913 ⟶ 1,631:
fmt.Println(longYears)
}
}</langsyntaxhighlight>
 
{{out}}
Line 926 ⟶ 1,644:
[2105 2111 2116 2122 2128 2133 2139 2144 2150 2156 2161 2167 2172 2178 2184 2189 2195]
</pre>
 
=={{header|GW-BASIC}}==
<lang gwbasic>10 INPUT "Enter a year: ", Y
20 X = Y
30 GOSUB 100
40 IF P = 4 THEN L = 1
50 X = Y - 1
60 GOSUB 100
70 IF P = 3 THEN L = 1
80 IF L = 1 THEN PRINT Y; " is a long year." ELSE PRINT Y;" is not a long year."
90 END
100 P = X + INT(X/4) - INT(X/100) + INT(X/400)
110 P = P MOD 7
120 RETURN</lang>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.Time.Calendar (fromGregorian)
import Data.Time.Calendar.WeekDate (toWeekDate)
 
Line 951 ⟶ 1,655:
 
main :: IO ()
main = mapM_ print $ filter longYear [2000 .. 2100]</langsyntaxhighlight>
{{Out}}
<pre>2004
Line 971 ⟶ 1,675:
2093
2099</pre>
 
=={{header|IS-BASIC}}==
<lang IS-BASIC>100 PROGRAM "Longyear.bas"
110 DEF RD(Y)=Y*365+INT(Y/4)-INT(Y/100)+INT(Y/400)
120 DEF LONGYEAR(Y)=(4=MOD(RD(Y),7)) OR(4=MOD((RD(Y-1)+1),7))
130 INPUT PROMPT "Start year: ":S
140 INPUT PROMPT "End year: ":E
150 FOR Y=S TO E
160 IF LONGYEAR(Y) THEN PRINT Y,
170 NEXT
180 PRINT</lang>
 
=={{header|J}}==
{{trans|C}}
<langsyntaxhighlight lang="j"> p =: 1 4 _100 400&(7 | [: <. +/ @: %~)"1 0
ily =: (4=p) +. 3=p@:<:
ply =: (#~ ily)@:([ + 1+i.@:-~)</langsyntaxhighlight>
{{out}}
<pre>
Line 995 ⟶ 1,688:
=={{header|Java}}==
 
<langsyntaxhighlight lang="java">
import java.time.LocalDate;
import java.time.temporal.WeekFields;
Line 1,015 ⟶ 1,708:
 
}
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,024 ⟶ 1,717:
=={{header|JavaScript}}==
{{trans|TypeScript}}
<langsyntaxhighlight lang="javascript">const isLongYear = (year) => {
const jan1 = new Date(year, 0, 1);
const dec31 = new Date(year, 11, 31);
Line 1,034 ⟶ 1,727:
console.log(y)
}
}</langsyntaxhighlight>
 
{{Out}}
Line 1,052 ⟶ 1,745:
 
===Using Zeller's congruence===
<syntaxhighlight lang="jq">
<lang jq>
# Use Zeller's Congruence to determine the day of the week, given
# year, month and day as integers in the conventional way.
Line 1,077 ⟶ 1,770:
 
"Long years from 1900 to 2100 inclusive:",
([range(1900;2101) | select(has53weeks)] | nwise(10) | join(", "))</langsyntaxhighlight>
{{out}}
<pre>
Line 1,088 ⟶ 1,781:
 
===Using mktime and gmtime===
<langsyntaxhighlight lang="jq"># Use jq's mktime and gmtime to produce the day of week,
# with 0 for Sunday, 1 for Monday, etc
# $year $month $day are conventional
Line 1,103 ⟶ 1,796:
 
"Long years from 1900 to 2100 inclusive:",
([range(1900;2101) | select(has53weeks)] | nwise(10) | join(", "))</langsyntaxhighlight>
{{out}}
As above.
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Dates
 
has53weeks(year) = week(Date(year, 12, 28)) == 53
Line 1,116 ⟶ 1,809:
println(year, " ", has53weeks(year) ? "Yes" : "No")
end
</langsyntaxhighlight>{{out}}
<pre>
Year 53 weeks?
Line 1,155 ⟶ 1,848:
 
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">
<lang Kotlin>
fun main() {
val has53Weeks = { year: Int -> LocalDate.of(year, 12, 28).get(WeekFields.ISO.weekOfYear()) == 53 }
Line 1,162 ⟶ 1,855:
.forEach { year -> print("$year ")}
}
</syntaxhighlight>
</lang>
{{out}}
<pre style="height35ex">
Line 1,170 ⟶ 1,863:
 
 
 
=={{header|Logo}}==
{{works with|UCB Logo}}
<syntaxhighlight lang="logo">to div :x :y
output int quotient :x :y
end
 
to dec31_weekday :year
output remainder (sum :year div :year 4 div :year -100 div :year 400) 7
end
 
to iso_long_year? :year
output or 4 = dec31_weekday :year 3 = dec31_weekday difference :year 1
end
 
for [y 1995 2045 1] [if iso_long_year? :y [print :y]]</syntaxhighlight>
 
{{Out}}
<pre>1998
2004
2009
2015
2020
2026
2032
2037
2043</pre>
 
=={{header|Lua}}==
<syntaxhighlight lang="lua">function isLongYear (y)
local function p (y)
local f = math.floor
return (y + f(y/4) - f(y/100) + f(y/400)) % 7
end
return p(y) == 4 or p(y - 1) == 3
end
 
print("Long years in the 21st century:")
for year = 2001, 2100 do
if isLongYear(year) then io.write(year .. " ") end
end</syntaxhighlight>
{{out}}
<pre>Long years in the 21st century:
2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">firstyear = 2000;
lastyear = 2099;
years = Range[firstyear, lastyear];
Line 1,180 ⟶ 1,917:
If[firstday[[n]] == Thursday || lastday[[n]] == Thursday,
Style[years[[n]] " long year \n", Bold, Red] ,
years[[n]] " short \n"], "error \n"], {n, Length[years]}]</langsyntaxhighlight>
{{out}}
<pre style="height:35ex">{2000 short
Line 1,285 ⟶ 2,022:
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE LongYear;
FROM InOut IMPORT WriteCard, WriteLn;
 
Line 1,306 ⟶ 2,043:
END;
END;
END LongYear.</langsyntaxhighlight>
{{out}}
<pre>2004
Line 1,328 ⟶ 2,065:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import times
 
proc has53weeks(year: Positive): bool =
Line 1,338 ⟶ 2,075:
for year in 2000..2100:
if year.has53weeks:
echo year</langsyntaxhighlight>
 
{{out}}
Line 1,362 ⟶ 2,099:
 
=={{header|МК-61/52}}==
<langsyntaxhighlight lang="mk-61">П0 ИП0 4 / [x] + ИП0 1 ВП 2
/ [x] - ИП0 4 ВП 2 / [x] +
^ ^ 7 / [x] 7 * - П1 4
- x#0 40 ИП1 3 - x#0 40 0 С/П
1 С/П</langsyntaxhighlight>
{{out}}
<pre>
Line 1,372 ⟶ 2,109:
</pre>
=={{header|Pascal}}==
<langsyntaxhighlight lang="pascal">program long_year(input);
var
y: integer;
Line 1,406 ⟶ 2,143:
if long_year(y) then
writeln(y)
end.</langsyntaxhighlight>
{{Out}}
<pre>1993
Line 1,421 ⟶ 2,158:
==={{header|Free Pascal}}===
Using DateUtils and WeeksInYear to not reinvent this.
<langsyntaxhighlight lang="pascal">
program Long_year;
 
Line 1,454 ⟶ 2,191:
Readln;
{$ENDIF}
end.</langsyntaxhighlight>
{{out}}
<pre>
Line 1,467 ⟶ 2,204:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use DateTime;
Line 1,476 ⟶ 2,213:
}
print "\n";
}</langsyntaxhighlight>
{{out}}
<pre>1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959 1964 1970 1976 1981 1987 1992 1998
Line 1,483 ⟶ 2,220:
 
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(phixonline)-->
Requires 0.8.1+
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<lang Phix>include builtins\ordinal.e
<span style="color: #008080;">function</span> <span style="color: #000000;">week_number</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">)</span>
 
<span style="color: #004080;">integer</span> <span style="color: #000000;">doy</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">day_of_year</span><span style="color: #0000FF;">(</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">),</span>
function week_number(integer y,m,d)
<span style="color: #000000;">dow</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">day_of_week</span><span style="color: #0000FF;">(</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">),</span>
integer doy = day_of_year(y,m,d),
<span style="color: #000000;">week</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #000000;">doy</span><span style="color: #0000FF;">-</span><span style="color: #000000;">dow</span><span style="color: #0000FF;">+</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">7</span><span style="color: #0000FF;">)</span>
dow = day_of_week(y,m,d),
<span style="color: #008080;">return</span> <span style="color: #000000;">week</span>
week = floor((doy-dow+10)/7)
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
return week
end function
<span style="color: #008080;">for</span> <span style="color: #000000;">c</span><span style="color: #0000FF;">=</span><span style="color: #000000;">20</span> <span style="color: #008080;">to</span> <span style="color: #000000;">22</span> <span style="color: #008080;">do</span>
 
<span style="color: #004080;">sequence</span> <span style="color: #000000;">long_years</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
for c=20 to 22 do
<span style="color: #004080;">integer</span> <span style="color: #000000;">century</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)*</span><span style="color: #000000;">100</span>
sequence long_years = {}
<span style="color: #008080;">for</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">=</span><span style="color: #000000;">century</span> <span style="color: #008080;">to</span> <span style="color: #000000;">century</span><span style="color: #0000FF;">+</span><span style="color: #000000;">99</span> <span style="color: #008080;">do</span>
integer century = (c-1)*100
<span style="color: #008080;">if</span> <span style="color: #000000;">week_number</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">,</span><span style="color: #000000;">12</span><span style="color: #0000FF;">,</span><span style="color: #000000;">28</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">53</span> <span style="color: #008080;">then</span>
for year=century to century+99 do
<span style="color: #000000;">long_years</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">year</span>
if week_number(year,12,28)=53 then
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
long_years &= year
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end if
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Long years in the %d%s century:%v\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">ord</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">),</span><span style="color: #000000;">long_years</span><span style="color: #0000FF;">})</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
printf(1,"Long years in the %d%s century:%v\n", {c,ord(c),long_years})
<!--</syntaxhighlight>-->
end for</lang>
{{out}}
<pre>
Line 1,509 ⟶ 2,246:
Long years in the 22nd century:{2105,2111,2116,2122,2128,2133,2139,2144,2150,2156,2161,2167,2172,2178,2184,2189,2195}
</pre>
 
 
=={{header|PHP}}==
<langsyntaxhighlight lang="php">function isLongYear($year) {
return (53 == strftime('%V', gmmktime(0,0,0,12,28,$year)));
}
Line 1,520 ⟶ 2,256:
printf("%s\n", $y);
}
}</langsyntaxhighlight>
{{Out}}
<pre>1998
Line 1,531 ⟶ 2,267:
2037
2043</pre>
 
=={{header|PL/0}}==
{{trans|Commodore BASIC}}
The program waits for two numbers: <code>startyear</code> and <code>endyear</code>. Then displays long years from <code>startyear</code> to <code>endyear</code>.
<syntaxhighlight lang="pascal">
var startyear, endyear, year, longyear, ayear, weekday;
 
procedure calcweekday;
begin
weekday := ayear + ayear / 4 - ayear / 100 + ayear / 400;
weekday := weekday - (weekday / 7) * 7
end;
 
procedure calclongyear;
begin
longyear := 0; ayear := year;
call calcweekday;
if weekday = 4 then longyear := 1;
ayear := year - 1;
call calcweekday;
if weekday = 3 then longyear := 1
end;
 
begin
? startyear;
? endyear;
year := startyear;
while year <= endyear do
begin
call calclongyear;
if longyear <> 0 then ! year;
year := year + 1
end
end.
</syntaxhighlight>
{{in}}
<pre>1995
2045</pre>
{{out}}
<pre>
1998
2004
2009
2015
2020
2026
2032
2037
2043
</pre>
 
=={{header|PowerShell}}==
<langsyntaxhighlight lang="powershell">Function Is-Long-Year {
param([Int]$year)
53 -eq (Get-Date -Year $year -Month 12 -Day 28 -UFormat %V)
Line 1,542 ⟶ 2,328:
Write-Host $y
}
}</langsyntaxhighlight>
 
{{Out}}
Line 1,558 ⟶ 2,344:
{{trans|C++}}
{{works with|SWI Prolog}}
<langsyntaxhighlight lang="prolog">% See https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
 
p(Year, P):-
Line 1,595 ⟶ 2,381:
 
main:-
print_long_years(1800, 2100).</langsyntaxhighlight>
 
{{out}}
Line 1,607 ⟶ 2,393:
2082 2088 2093 2099
</pre>
 
 
=={{header|PureBasic}}==
{{trans|BASIC256}}
<lang PureBasic>Procedure.b p(y)
ProcedureReturn (y + Int(y/4) - Int(y/100) + Int(y/400)) % 7
EndProcedure
 
Procedure.b isLongYear(y)
ProcedureReturn Bool((p(y) = 4) Or (p(y - 1) = 3))
EndProcedure
 
If OpenConsole()
For y = 2000 To 2100
If isLongYear(y)
PrintN(Str(y))
EndIf
Next y
Print(""): Input()
CloseConsole()
EndIf</lang>
{{out}}
<pre>
Igual que la entrada de BASIC256.
</pre>
 
 
=={{header|Python}}==
{{Works with|Python|3.7}}
<langsyntaxhighlight lang="python">'''Long Year ?'''
 
from datetime import date
Line 1,661 ⟶ 2,420:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>2004
Line 1,686 ⟶ 2,445:
<code>dayofweek</code> is defined at [[Day of the week#Quackery]]
 
<langsyntaxhighlight Quackerylang="quackery"> [ dup dip
[ 1 1 rot dayofweek 4 = ]
31 12 rot dayofweek 4 = or ] is longyear ( n --> b )
Line 1,694 ⟶ 2,453:
100 times
[ 2000 i^ + longyear if
[ 2000 i^ + echo sp ] ]</langsyntaxhighlight>
 
{{out}}
Line 1,702 ⟶ 2,461:
2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099 </pre>
 
=={{header|Quick BASIC}}==
{{Works with|QB|4.x}}
{{Works with|PDS|7.x}}
{{Works with|QBasic|1.x}}
{{Works with|VB-DOS|1.0}}
Translated from Delphi
<lang vb>
DEFINT A-Z
 
DECLARE FUNCTION p% (Yr AS INTEGER)
DECLARE FUNCTION LongYear% (Yr AS INTEGER)
 
DIM iYi, iYf, i
 
CLS
PRINT "This program calculates which are 53-week years in a range."
PRINT
INPUT "Initial year"; iYi
INPUT "Final year (could be the same)"; iYf
IF iYf >= iYi THEN
FOR i = iYi TO iYf
IF LongYear(i) THEN
PRINT i; " ";
END IF
NEXT i
END IF
PRINT
PRINT
PRINT "End of program."
END
 
FUNCTION LongYear% (Yr AS INTEGER)
LongYear% = (p%(Yr) = 4) OR (p%(Yr - 1) = 3)
END FUNCTION
 
FUNCTION p% (Yr AS INTEGER)
p% = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
</lang>
{{Out}}
<pre>
This program calculates which are 53-week years in a range.
 
Initial year? 1900
Final year (can be the same)? 1999
1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959
1964 1970 1976 1981 1987 1992 1998
 
End of program.
</pre>
 
=={{header|Raku}}==
Line 1,757 ⟶ 2,466:
{{works with|Rakudo|2019.11}}
December 28 is always in the last week of the year. (By ISO8601)
<syntaxhighlight lang="raku" perl6line>sub is-long ($year) { Date.new("$year-12-28").week[1] == 53 }
 
# Testing
say "Long years in the 20th century:\n", (1900..^2000).grep: &is-long;
say "\nLong years in the 21st century:\n", (2000..^2100).grep: &is-long;
say "\nLong years in the 22nd century:\n", (2100..^2200).grep: &is-long;</langsyntaxhighlight>
{{out}}
<pre>Long years in the 20th century:
Line 1,774 ⟶ 2,483:
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/*REXX program determines ifIf a (calendar) year is a SHORTshort or LONGlong year (52 or 53 weeks).*/
parse/* arg LO HI . /*obtain optional args. (52 or 53 weeks). */
Parse Arg lo hi . /* obtain optional args. */
if LO=='' | LO=="," | LO=='*' then LO= left( date('S'), 4) /*Not given? Use default.*/
current=left(date('S'),4)
if HI=='' | HI=="," then HI= LO /* " " " " */
If lo=='' | lo=="," | lo=='*' Then lo=current /*Not given? Use default.*/
if HI=='*' then HI= left( date('S'), 4) /*an asterisk ≡ current yr*/
If hi=='' | hi=="," Then hi=lo /* " " " " */
If hi=='*' Then hi=current /*an asterisk: current yr*/
 
Do do jyr=LO to HI lo To hi /* process single yr or range of years.*/
saySay ' year ' yr j "' is a " right( word('short long', weeks(j)-51),5) " year"
right(word('short long',is_long(yr)+1),5) ' year'
end /*j*/
End
exit 0 /*stick a fork in it, we're all done. */
Exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*----------------------------------------------------------------------*/
pWeek: parse arg #; return (# + # % 4 - # % 100 + # % 400) // 7
wd_1231:
weeks: parse arg y; if pWeek(y)==4 | pWeek(y-1)==3 then return 53; return 52</lang>
/*************************************************************************
* returns the day of the week of 31 December year
*************************************************************************/
Parse Arg year
Return (year+year%4-year%100+year%400)//7
 
is_long:
Parse Arg year
Return wd_1231(year)==4 |, /* year ends in a Thursday */
wd_1231(year-1)==3 /* or previous year ends in a Wednesday */</syntaxhighlight>
{{out|output|text=&nbsp; when using the inputs of: &nbsp; &nbsp; <tt> 1990 &nbsp; 2030 </tt>}}
 
Line 1,835 ⟶ 2,556:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
see "long years 2000-2099: "
for year = 2000 to 2100
Line 1,845 ⟶ 2,566:
ok
next
</syntaxhighlight>
</lang>
{{out}}
<pre>
long years 2000-2099: 2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099
</pre>
 
=={{header|RPL}}==
This is a direct transcription from [https://en.wikipedia.org/wiki/ISO%20week%20date Wikipedia's formula].
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! Code
! Comments
|-
|
DUP 1 -
1 2 '''START'''
→ y ≪ y DUP 4 / IP + y 100 / IP - y 400 / IP + 7 MOD ≫
SWAP
'''NEXT'''
3 == SWAP 4 == OR
≫ 'LONG?' STO
|
( year -- weekday )
Calling 2 times...
... p() as a nested function, to get p(y-1)...
...then p(y)
|}
The following line of code delivers what is required:
≪ {} 2023 2100 '''FOR''' y '''IF''' y LONG? '''THEN''' y + '''END NEXT''' ≫ EVAL
{{out}}
<pre>
1: { 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099 }
</pre>
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">
require 'date'
 
Line 1,860 ⟶ 2,614:
 
(2020..2030).each{|year| puts "#{year} is long? #{ long_year?(year) }." }
</syntaxhighlight>
</lang>
{{out}}
<pre>2020 is long? true.
Line 1,877 ⟶ 2,631:
=={{header|Rust}}==
 
<langsyntaxhighlight Rustlang="rust">extern crate time; // 0.2.16
 
use time::Date;
Line 1,890 ⟶ 2,644:
Date::try_from_ymd(year, 12, 28).map_or(false, |date| date.week() == 53)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,911 ⟶ 2,665:
2093
2099
</pre>
 
=={{header|S-Basic}}==
<lang BASIC>
$lines
 
rem - compute p mod q
function mod(p, q = integer) = integer
end = p - q * (p/q)
 
comment
return day of week (Sun = 0, Mon = 1, etc.) for a
given Gregorian calendar date using Zeller's congruence
end
function dayofweek (mo, da, yr = integer) = integer
var y, c, z = integer
if mo < 3 then
begin
mo = mo + 10
yr = yr - 1
end
else mo = mo - 2
y = mod(yr,100)
c = int(yr / 100)
z = int((26 * mo - 2) / 10)
z = z + da + y + int(y/4) + int(c/4) - 2 * c + 777
z = mod(z,7)
end = z
 
comment
The simplest of several possible tests is that
any calendar year starting or ending on a
Thursday is "long", i.e., has 53 ISO weeks
end
function islongyear(yr = integer) = integer
var thursday, result = integer
thursday = 4
if (dayofweek(1,1,yr) = thursday) or \
(dayofweek(12,31,yr) = thursday) then
result = -1 rem "true"
else
result = 0 rem "false"
end = result
 
rem - main program begins here
 
var year = integer
print "ISO years that will be long in this century:"
for year = 2000 to 2099
if islongyear(year) then print year;
next year
 
end</lang>
{{output}}
<pre>
ISO years that will be long in this century:
2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088
2093 2099
</pre>
 
Line 1,974 ⟶ 2,670:
{{Out}}Best seen running in your browser by [https://scastie.scala-lang.org/LDKMJ29SSrehyVbCmiMH1Q Scastie (remote JVM)].
 
<langsyntaxhighlight Scalalang="scala">import java.time.temporal.TemporalAdjusters.firstInMonth
import java.time.temporal.{ChronoField, IsoFields}
import java.time.{DayOfWeek, LocalDate, Month}
Line 2,020 ⟶ 2,716:
results.zipWithIndex.foreach(solution => println(s"Solution ${solution._2}: ${solution._1.mkString(" ")}"))
 
}</langsyntaxhighlight>
 
=={{header|Scheme}}==
Line 2,029 ⟶ 2,725:
The demo code uses <tt>iota</tt> as defined in SRFI-1, so won't work in Schemes lacking that function. Racket requires the addition of <tt>(require srfi/1)</tt>.
 
<langsyntaxhighlight lang="scheme">(define (dec31wd year)
(remainder (apply + (map (lambda (d) (quotient year d)) '(1 4 -100 400))) 7))
 
Line 2,035 ⟶ 2,731:
 
(display "Long years between 1800 and 2100:") (newline)
(display (filter long? (iota 300 1800)))</langsyntaxhighlight>
 
{{Out}}
Line 2,042 ⟶ 2,738:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">func is_long_year(year) {
Date.parse("#{year}-12-28", "%Y-%m-%d").week == 53
}
Line 2,048 ⟶ 2,744:
say ( "Long years in the 20th century:\n", (1900..^2000).grep(is_long_year))
say ("\nLong years in the 21st century:\n", (2000..^2100).grep(is_long_year))
say ("\nLong years in the 22nd century:\n", (2100..^2200).grep(is_long_year))</langsyntaxhighlight>
{{out}}
<pre>
Line 2,062 ⟶ 2,758:
 
=={{header|Snobol}}==
<langsyntaxhighlight lang="snobol"> DEFINE('DEC31WD(Year)') :(END_DEC31WD)
DEC31WD DEC31WD = REMDR(Year + (Year / 4) - (Year / 100) + (Year / 400), 7) :(RETURN)
END_DEC31WD
 
DEFINE('ISOLONG(Year)') :(END_ISOLONG)
ISOLONG EQ(DEC31WD(Year), 4) :S(RETURN)
EQ(DEC31WD(Year - 1), 3) :S(RETURN)F(FRETURN)
END_ISOLONG
 
YEARDEFINE('ISODEMO(Start,End)') = 1995:(END_ISODEMO)
ISODEMO OUTPUT = 'ISO long years between ' Start ' and ' End ':'
LOOP OUTPUT = ISOLONG(YEAR) YEAR
YEARYear = YEAR + 1 Start
LOOP OUTPUT = LTISOLONG(YEAR, 2045Year) :S(LOOP)Year
Year = Year + 1
END</lang>
LE(YEAR, 2045) :S(LOOP) F(RETURN)
END_ISODEMO
 
ISODEMO(1995, 2045)
END</syntaxhighlight>
 
{{Out}}
<pre>ISO long years between 1995 and 2045:
<pre>1998
1998
2004
2009
Line 2,089 ⟶ 2,791:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">func isLongYear(_ year: Int) -> Bool {
let year1 = year - 1
let p = (year + (year / 4) - (year / 100) + (year / 400)) % 7
Line 2,099 ⟶ 2,801:
for range in [1900...1999, 2000...2099, 2100...2199] {
print("\(range): \(range.filter(isLongYear))")
}</langsyntaxhighlight>
 
{{out}}
Line 2,110 ⟶ 2,812:
 
{{trans|C++}}
<syntaxhighlight lang="tcl">
<lang Tcl>
## Reference: https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
 
Line 2,135 ⟶ 2,837:
puts "Long years between 1800 and 2100:"
print_long_years 1800 2100
puts ""</langsyntaxhighlight>
{{out}}
<pre>
Line 2,148 ⟶ 2,850:
 
=={{header|Terraform}}==
{{works with|Terraform|0.13+}}
Contents of main module:
 
<langsyntaxhighlight lang="terraform">module "iso-long-years" {
source = "./iso-long-years"
start_year = 1995
Line 2,159 ⟶ 2,861:
output "long-years" {
value = module.iso-long-years.long-years
}</langsyntaxhighlight>
 
Contents of <tt>iso-long-years</tt> module:
 
<langsyntaxhighlight lang="terraform">variable start_year {
type = number
}
Line 2,184 ⟶ 2,886:
value = compact([for y in [for n in local.year_list: tostring(n)]:
module.iso-long-year[y].isLong ? y : ""])
}</langsyntaxhighlight>
 
Contents of <tt>iso-long-year</tt> module:
 
<langsyntaxhighlight lang="terraform">variable year {
type = string
default = ''""
}
 
Line 2,203 ⟶ 2,905:
output isLong {
value = (local.dec31 % 7 == 4 || local.jan1 % 7 == 4)
}</langsyntaxhighlight>
 
{{Out}}
Line 2,222 ⟶ 2,924:
"2043",
]</pre>
 
=={{header|Tiny BASIC}}==
<lang tiny basic> PRINT "What year would you like?"
INPUT Y
LET X = Y
GOSUB 100
IF P = 4 THEN LET L = 1
LET X = Y - 1
GOSUB 100
IF P = 3 THEN LET L = 1
IF L = 1 THEN PRINT Y," is a long year."
IF L = 0 THEN PRINT Y," is not a long year."
END
100 LET P = X + X/4 - X/100 + X/400
110 IF P < 7 THEN RETURN
LET P = P - 7
GOTO 110
</lang>
{{out}}
<pre>
What year would you like?
2020
2020 is a long year.
 
What year would you like?
2021
2021 is not a long year.
</pre>
 
 
=={{header|True BASIC}}==
{{trans|BASIC256}}
<lang qbasic>FUNCTION p(y) = REMAINDER((y + INT(y/4) - INT(y/100) + INT(y/400)), 7)
 
FUNCTION isLongYear(y)
IF p(y) = 4 THEN
LET isLongYear = 1
ELSEIF p(y-1) = 3 THEN
LET isLongYear = 1
ELSE
LET isLongYear = 0
END IF
END FUNCTION
 
FOR y = 2000 TO 2100
IF isLongYear(y) > 0 THEN PRINT y
NEXT y
END</lang>
{{out}}
<pre>
Igual que la entrada de BASIC256.
</pre>
 
 
=={{header|TypeScript}}==
<langsyntaxhighlight lang="typescript">const isLongYear = (year: number): boolean => {
const jan1: Date = new Date(year, 0, 1);
const dec31: Date = new Date(year, 11, 31);
Line 2,287 ⟶ 2,935:
console.log(y)
}
}</langsyntaxhighlight>
 
{{Out}}
Line 2,303 ⟶ 2,951:
 
=== Thursdays check using cal(1) and grep(1) ===
<langsyntaxhighlight lang="sh">long_year() {
cal 1 $1 | grep -q ' 3 *$' && return 0
cal 12 $1 | grep -q ' 26 *$'
}</langsyntaxhighlight>
 
=== Straightforward check using GNU date(1) ===
December 28th is always in the last week of the year, so just check whether or not that's week 53:
<lang sh>long_year() {
 
<syntaxhighlight lang="sh">long_year() {
expr $(date -d "$1-12-28" +%V) = 53 >/dev/null
}</langsyntaxhighlight>
 
=== Direct computation with built-in arithmetic in newer shells ===
Line 2,317 ⟶ 2,967:
{{works with|Korn Shell}}
{{works with|Zsh}}
<langsyntaxhighlight lang="sh">dec31wd() {
# return weekday (time_t tm_wday, 0=Sunday) of December 31st of the given year
typeset -i y=$1
echo $(( (y + y / 4 - y / 100 + y / 400) % 7 ))
}
 
# the year is long if the year starts or ends on a Thursday (starts on a
# Thursday = the previous year ends on a Wednesday)
long_year() {
typeset -i y=$1
(( 4 == $(dec31wd $y) || 3 == $(dec31rddec31wd $(( y - 1 ))) ))
}</langsyntaxhighlight>
 
Demo code for any of the above:
 
<syntaxhighlight lang ="sh"> for y in $(seq 1995 2045); do
if long_year $y; then
echo $y
fi
done | column
</syntaxhighlight>
</lang>
 
{{Out}}
<pre>1998 2004 2009 2015 2020 2026 2032 2037 2043</pre>
 
=={{header|Visual Basic}}==
{{works with|Visual Basic|5}}
{{works with|Visual Basic|6}}
{{works with|VBA|Access 97}}
{{works with|VBA|6.5}}
{{works with|VBA|7.1}}
<lang vb>Option Explicit
 
Function IsLongYear(ByVal Year As Integer) As Boolean
Select Case vbThursday
Case VBA.DatePart("w", VBA.DateSerial(Year, 1, 1)), _
VBA.DatePart("w", VBA.DateSerial(Year, 12, 31))
IsLongYear = True
End Select
End Function
 
Sub Main()
'test
Dim l As Long
For l = 1990 To 2021
Select Case l
Case 1992, 1998, 2004, 2009, 2015, 2020
Debug.Assert IsLongYear(l)
Case Else
Debug.Assert Not IsLongYear(l)
End Select
Next l
End Sub
</lang>
 
==={{header|Visual Basic for DOS}}===
Translated from Delohi
<lang vb>OPTION EXPLICIT
 
DECLARE FUNCTION p (Yr AS INTEGER) AS INTEGER
DECLARE FUNCTION LongYear (Yr AS INTEGER) AS INTEGER
 
DIM iYi AS INTEGER, iYf AS INTEGER, i AS INTEGER
 
CLS
PRINT "This program calculates which are 53-week years in a range."
PRINT
INPUT "Initial year"; iYi
INPUT "Final year (could be the same)"; iYf
IF iYf >= iYi THEN
FOR i = iYi TO iYf
IF LongYear(i) THEN
PRINT i; " ";
END IF
NEXT i
END IF
PRINT
PRINT
PRINT "End of program."
END
 
FUNCTION p (Yr AS INTEGER) AS INTEGER
p = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
 
FUNCTION LongYear (Yr AS INTEGER) AS INTEGER
LongYear = (p(Yr) = 4) OR (p(Yr - 1) = 3)
END FUNCTION
</lang>
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|Wren-date}}
<langsyntaxhighlight ecmascriptlang="wren">import "./date" for Date
 
var centuries = ["20th", "21st", "22nd"]
Line 2,421 ⟶ 3,009:
}
System.print(longYears)
}</langsyntaxhighlight>
 
{{out}}
Line 2,435 ⟶ 3,023:
</pre>
 
=={{header|XPL0}}==
{{trans|Commodore BASIC}}
{{works with|EXPL-32}}
<syntaxhighlight lang="xpl0">
\Long year
code Rem=2, CrLf=9, IntIn=10, IntOut=11, Text=12, Clear=40;
integer S, E, Y;
function integer Weekday(Y);
\Weekday of Y-12-31, 0 Sunday
integer Y;
return Rem((Y + Y / 4 - Y / 100 + Y / 400) / 7);
 
function integer IsLongYear(Y);
=={{header|Yabasic}}==
integer Y;
{{trans|BASIC256}}
return 4 = Weekday(Y) ! 3 = Weekday(Y - 1);
<lang yabasic>sub p(y)
return mod((y + int(y/4) - int(y/100) + int(y/400)), 7)
end sub
 
begin
sub isLongYear(y)
Clear;
return (p(y) = 4) or (p(y - 1) = 3)
Text(0, "**** List of ISO long years ****");
end sub
CrLf(0);
 
Text(0, "Start year: "); S:= IntIn(0);
for y = 2000 to 2100
Text(0, "End year: "); E:= IntIn(0);
if isLongYear(y) then print y : fi
CrLf(0);
next y
for Y:= S, E do
end</lang>
if IsLongYear(Y) then [IntOut(0, Y); Text(0, " ")];
CrLf(0);
end
</syntaxhighlight>
{{out}}
<pre>
**** List of ISO long years ****
Igual que la entrada de BASIC256.
Start year: 1995
End year: 2045
 
1998 2004 2009 2015 2020 2026 2032 2037 2043
</pre>
 
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">fcn isLongYear(y){ Time.Date.weeksInYear(y)==53 }
foreach nm,y in (T(T("20th",1900), T("21st",2000), T("22nd",2100))){
println("\nLong years in the %s century:\n%s".fmt(nm,
[y..y+99].filter(isLongYear).concat(" ")));
}</langsyntaxhighlight>
{{out}}
<pre>
2,041

edits