Easter Day (calculation algorithm)

maXim

Active Member
Licensed User
Longtime User
Hi Everyone,

a simple solution to detect the Easter day:
 

Attachments

  • easter_day.sbp
    3.5 KB · Views: 431

alfcen

Well-Known Member
Licensed User
Longtime User
Ciao MaXim

Wow, your coding required a great deal of concentration.
Here is a shorter version:

B4X:
Sub DateOfEaster(y)
  Dim c, n, k, i, j, l, m, d
  c = Int(y / 100)
  n = y - 19 * int( y / 19 )
  k = int(( c - 17 ) / 25)
  i = Int(c - int(c / 4) - ( c - k ) / 3 + 19 * n + 15)
  i = i - 30 * int( i / 30 )
  i = i - int(i / 28 ) * ( 1 - int( i / 28 ) * int( 29 / ( i + 1 ) ) * int( ( 21 - n ) / 11 ) )
  j = y + int(y / 4) + i + 2 - c + int(c / 4)
  j = j - 7 * int( j / 7 )
  l = i - j
  m = int(3 + (l + 40 ) / 44)
  d = l + 28 - 31 * int( m / 4 )
  if m = 3 Then Return "March " & d
  if m = 4 Then Return "April " & d
End Sub

Perhaps a later version of B4P will add the "\" operator.

Feel free to use or abuse

Roberto
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…