# 计算复活节的日期

13

``````e(5701583) = 5701583-04-10
e(2013)    = 2013-03-31
e(1583)    = 1583-04-10
e(3029)    = 30290322
e(1789)    = 17890412
e(1725)    = 17250401
``````

Fors

1

jdstankosky

3

## GolfScript（85个字符）

``````~:^100/.)3*4/.@8*13+25/-^19%.19*15+@+30%.@11/+29/23--.@-^.4/++7%97--^0@.31/100*\31%)+
``````

``````\$ golfscript.rb codegolf11132.gs <<<2013
20130331
``````

``````K = Y/100
M = 15 + (3*K+3)/4 - (8*K+13)/25
S = 2 - (3*K+3)/4
A = Y%19
D = (19*A+M) % 30
R = (D + A/11)/29
OG = 21 + D - R
SZ = 7 - (Y + Y/4 + S) % 7
OE = 7 - (OG-SZ) % 7
return OG + OE + 92
``````

``````K = y/100
k = (3*K+3)/4
A = y%19
D = (19*A+15+k-(8*K+13)/25)%30
G = 23+D-(D+A/11)/29
return 97+G-(G+y+y/4-k)%7
``````

2013年

@Fors，哎呀。现在已修复。

5

# 蟒2 - 125 120 119个字符

``````y=input()
a=y/100*1483-y/400*2225+2613
b=(y%19*3510+a/25*319)/330%29
b=148-b-(y*5/4+a-b)%7
print(y*100+b/31)*100+b%31+1
``````

Edit2：感谢Peter Taylor展示了如何摆脱它`10000`并节省1个字符。

1

@PeterTaylor：很好的建议。更新了我的答案。
Steven Rumbalski

sagiksp

4

# PHP 154

``````<?\$y=\$argv[1];\$a=\$y/100|0;\$b=\$a>>2;\$c=(\$y%19*351-~(\$b+\$a*29.32+13.54)*31.9)/33%29|0;\$d=56-\$c-~(\$a-\$b+\$c-24-\$y/.8)%7;echo\$d>31?"\$y-04-".(\$d-31):"\$y-03-\$d";
``````

``````<?
\$y = \$argv[1];
\$a = \$y / 100 |0;
\$b = \$a >> 2;
\$c = (\$y % 19 * 351 - ~(\$b + \$a * 29.32 + 13.54) * 31.9) / 33 % 29 |0;
\$d = 56 - \$c - ~(\$a - \$b + \$c - 24 - \$y / .8) % 7;
echo \$d > 31 ? "\$y-04-".(\$d - 31) : "\$y-03-\$d";
``````

1

Titus

4

# dc：106个字符

``````?[0n]smdndsy100/1483*ly400/2225*-2613+dsa25/319*ly19%3510*+330/29%sb148lb-5ly*4/la+lb-7%-d31/0nn31%1+d9>mp
``````

``````> dc -e "?[0n]smdndsy100/1483*ly400/2225*-2613+dsa25/319*ly19%3510*+330/29%sb148lb-5ly*4/la+lb-7%-d31/0nn31%1+d9>mp"
1725
17250401
>
``````

3

# C：151个 148字符

``````y;a;b;main(){scanf("%d",&y);a=y/100*1483-y/400*2225+2613;b=(y%19*3510+a/25*319)/330%29;b=148-b-(y*5/4+a-b)%7;printf("%d-0%d-%02d\n",y,b/31,b%31+1);}
``````

``````#include <stdio.h>

int y, a, b;

int main() {
scanf("%d", &y);

a = y/100*1483 - y/400*2225 + 2613;
b = (y%19*3510 + a/25*319)/330%29;
b = 148 - b - (y*5/4 + a - b)%7;

printf("%d-0%d-%02d\n", y, b/31, b%31 + 1);
}
``````

3

# JavaScript的162 156 145

``````function e(y){alert(y+"0"+((d=56-(c=(y%19*351-~((b=(a=y/100|0)>>2)+a*29.32+13.54)*31.9)/33%29|0)-~(a-b+c-24-y/.8)%7)>(f=31)?4:3)+(d-f>0&d-f<10?0:"")+(d>f?d-f:d))}
``````

``````alert((y=prompt())+0+((d=56-(c=(y%19*351-~((b=(a=y/100|0)>>2)+a*29.32+13.54)*31.9)/33%29|0)-~(a-b+c-24-y/.8)%7)>(f=31)?4:3)+(d-f>0&d-f<10?0:"")+(d>f?d-f:d))
``````

`e=y=>y+"0"+((d=56-(c=(y%19*351-31.9*~((b=(a=y/100|0)>>2)+29.32*a+13.54))/33%29|0)-~(a-b+c-24-y/.8)%7)>(f=31)?4:3)+(d-f>0&d-f<10?0:"")+(d>f?d-f:d)`

2

## APL 132

``````E y
(a b)←⌊((3 8×⌊y÷100)+¯5 13)÷4 25
c←7|y+(⌊y÷4)-a-e←⌊d-((19×d←30|(227-(11×c)-a-b))+c←19|y)÷543
+/(10*4 2 0)×y,(3+i>31),(61⍴⍳31)[i←e+28-c]
``````

``````      E 2013
20130331
E 1583
15830410
E 3029
30290322
E 1789
17890412
``````

0

# Fortran（GFortran），179个字节

``````READ*,I
J=I/100*2967-I/400*8875+7961
K=MOD(MOD(I,19)*6060+(MOD(MOD(J/25,59),30)+23)*319-1,9570)/330
L=K+28-MOD(I*5/4+J+K,7)
WRITE(*,'(I7,I0.2,I0.2)')I,(L-1)/31+3,MOD(L-1,31)+1
END
``````