Day of the week: Difference between revisions

no edit summary
No edit summary
Line 169:
}
</lang>
 
=={{header|BASIC}}==
<b>Works with:</b> FreeBASIC
This program needs the modulo function because there is a bug in the built in modulo function.
 
<lang BASIC>Declare Function modulo(x As Double, y As Double) As Double
Declare Function wd(m As Double, d As Double, y As Double) As Integer
 
Cls
Dim yr As Double
For yr = 2008 To 2121
If wd(12,25,yr) = 1 Then
Print "Dec " & 25 & ", " & yr
EndIf
Next
Sleep
 
Function modulo(x As Double, y As Double) As Double
If y = 0 Then
Return x
Else
Return x - y * Int(x / y)
End If
End Function
 
Function wd(m As Double, d As Double, y As Double) As Integer
If m = 1 Or m = 2 Then
m += 12
y-= 1
End If
Return modulo(365 * y + Fix(y / 4) - Fix(y / 100) + Fix(y / 400) + d + Fix((153 * m + 8) / 5), 7) + 1
End Function
 
Dec 25, 2011
Dec 25, 2016
Dec 25, 2022
Dec 25, 2033
Dec 25, 2039
Dec 25, 2044
Dec 25, 2050
Dec 25, 2061
Dec 25, 2067
Dec 25, 2072
Dec 25, 2078
Dec 25, 2089
Dec 25, 2095
Dec 25, 2101
Dec 25, 2107
Dec 25, 2112
Dec 25, 2118</lang>
 
=={{header|BBC BASIC}}==
Line 824 ⟶ 874:
25th of December is a Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</pre>
 
=={{header|BASIC}}==
<b>Works with:</b> FreeBASIC
This program needs the modulo function because there is a bug in the built in modulo function.
 
<lang BASIC>Declare Function modulo(x As Double, y As Double) As Double
Declare Function wd(m As Double, d As Double, y As Double) As Integer
 
Cls
Dim yr As Double
For yr = 2008 To 2121
If wd(12,25,yr) = 1 Then
Print "Dec " & 25 & ", " & yr
EndIf
Next
Sleep
 
Function modulo(x As Double, y As Double) As Double
If y = 0 Then
Return x
Else
Return x - y * Int(x / y)
End If
End Function
 
Function wd(m As Double, d As Double, y As Double) As Integer
If m = 1 Or m = 2 Then
m += 12
y-= 1
End If
Return modulo(365 * y + Fix(y / 4) - Fix(y / 100) + Fix(y / 400) + d + Fix((153 * m + 8) / 5), 7) + 1
End Function
Dec 25, 2011
Dec 25, 2016
Dec 25, 2022
Dec 25, 2033
Dec 25, 2039
Dec 25, 2044
Dec 25, 2050
Dec 25, 2061
Dec 25, 2067
Dec 25, 2072
Dec 25, 2078
Dec 25, 2089
Dec 25, 2095
Dec 25, 2101
Dec 25, 2107
Dec 25, 2112
Dec 25, 2118</lang>
 
=={{header|GAP}}==