Skip to content

Commit ae22d4c

Browse files
authored
Improved julia implementation of Computus (#677)
1 parent cc06d33 commit ae22d4c

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

‎contents/computus/code/julia/gauss_easter.jl‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ function computus(year; servois=false)
22

33
# Year's position on the 19 year metonic cycle
44
a =mod(year, 19)
5-
5+
66
# Century index
7-
k =floor(Int, year/100)
7+
k =fld(year, 100)
88

99
# Shift of metonic cycle, add a day offset every 300 years
10-
p =floor(Int, (13+8* k) /25)
10+
p =fld(13+8* k, 25)
1111

1212
# Correction for non-observed leap days
13-
q =floor(Int, k /4)
13+
q =fld(k,4)
1414

1515
# Correction to starting point of calculation each century
1616
M =mod(15- p + k - q, 30)
@@ -20,7 +20,7 @@ function computus(year; servois=false)
2020

2121
# Returning if user wants value for Servois' table
2222
if servois
23-
returnmod(21+d,31)
23+
returnmod(21+d,31)
2424
end
2525

2626
# Finding the next Sunday
@@ -40,24 +40,23 @@ function computus(year; servois=false)
4040
end
4141

4242
# Determination of the correct month for Easter
43-
if(22+ d + e >31)
44-
return"April "*string(d + e -9)
43+
if(22+ d + e >31)
44+
return"April "*string(d + e -9)
4545
else
46-
return"March "*string(22+d+e)
46+
return"March "*string(22+ d +e)
4747
end
4848
end
4949

5050
# Here, we will output the date of the Paschal full moon
5151
# (using Servois notation), and Easter for 2020-2030
5252

53-
a =[i for i =2020:2030]
54-
servois_numbers =computus.(a;servois=true)
53+
a =collect(2020:2030)
54+
servois_numbers =computus.(a;servois=true)
5555
easter_dates =computus.(a)
5656

57-
println("The following are the dates of the Paschal full moon (using Servois "*
57+
println("The following are the dates of the Paschal full moon (using Servois "*
5858
"notation) and the date of Easter for 2020-2030 AD:")
59-
println("Year Servois number Easter")
59+
println("Year\tServois number\tEaster")
6060
for i =1:length(a)
61-
println(string(a[i])*"\t"*string(servois_numbers[i])*"\t\t"*
62-
string(easter_dates[i]))
61+
println("$(a[i])\t$(servois_numbers[i])\t\t\t\t$(easter_dates[i])")
6362
end

0 commit comments

Comments
(0)