James Buddenhagen <jbuddenh(a)gmail.com> wrote:
> Well, I get errors when I type that in. We must be on different
> operating systems.
The cal command should work on all Unix, Linux, and Mac OS X command
lines. Are any other command line interfaces (e.g. VMS, MS/DOS, ITS)
still in use?
Anyhow, the problem isn't actually about the actual cal command, but
about an idealized version of it.
"Adam P. Goucher" <apgoucher(a)gmx.com> wrote:
> The Gregorian calendar has a period of 400 years, so cal is a
> function of (year mod 400).
True, but years can have the same calendar even if they don't differ
by a multiple of 400. There are, after all, only 14 different
calendars in our system.
> This reduces the puzzle to a finite check.
I don't see how that follows. Indeed, it turns out there are an
infinite number of solutions. I suppose one could argue that they all
follow one of a finite number of distinct patterns.
Tom Duff <td(a)pixar.com> wrote:
> Sometime around 4140 AD, the Gregorian rule will lose
> synchronization with the equinoxes and an extra Feb 29 will
> be needed. So the result depends on what fix humanity adopts.
Not that soon, given that it's designed, not to track all equinoxes
and solstices equally, but only to track the vernal equinox. And it
really is very good at doing so. In the very long run, those average
out to the same, but not over a mere 3000 years or so. Anyhow, by the
time the predictable precession of the equinoxes makes a difference,
the less predictable irregular slowing of the Earth's rotation will
make a bigger difference.
Perhaps you underestimate what our descendants will be capable of
in another thousand years. They could resolve the Earth's slowing
rotation by transporting lots of mass to higher latitudes, which will
reduce its moment of inertia, meaning a higher rotation rate for the
same angular momentum. And they could build lots of tidal power
stations and run them in reverse to increase the angular momentum.
With these two processes they could restore Earth's rotation rate to
what it was when it was equivalent to atomic time (officially 1900,
but actually closer to 1850) and keep it there indefinitely.
Anyhow, I solved it for the simplest case, assuming the Gregorian
calendar had been in use since the year 1 and will remain in use
until the year 1 quintillion (10^18).
1 2 3 4 5 6 7 8 9 18 31 50 62 74 93 99 181 187 313 319 501 507 626 745
933 939 995 1810 1877 3130 3197 5014 5070 6265 7455 9333 9339 9395
9953 9959 18103 18773 18779 31975 50146 62654 74553 74559 93333 93339
93395 93953 93959 99531 99598 181038 187731 187798 319755 626541
626547 745534 745590 933333 933339 933395 933953 933959 939531 939598
995311 995981 995987 1877314 3197558 6265415 6265471 7455342 7455900
7455906 9333333 9333339 9333395 9333953 9333959 9339531 9339598
9395311 9395981 9395987 9953114 9959818 9959874 18773145 31975586
62654158 62654711 74553421 74553427 74559066 93333333 93333339
93333395 93333953 93333959 93339531 93339598 93395311 93395981
93395987 93953114 93959818 93959874 99531142 99598189 99598742
187731455 319755862 626541589 626547111 745534210 745534277 745590666
933333333 933333339 933333395 933333953 933333959 933339531 933339598
933395311 933395981 933395987 933953114 933959818 933959874 939531142
939598189 939598742 995311429 995981891 995987429 1877314553
1877314559 3197558623 6265415893 6265415899 6265471111 7455342103
7455342773 7455342779 7455906666 9333333333 9333333339 9333333395
9333333953 9333333959 9333339531 9333339598 9333395311 9333395981
9333395987 9333953114 9333959818 9333959874 9339531142 9339598189
9339598742 9395311429 9395981891 9395987429 9953114291 9959818911
9959874291 18773145534 18773145590 31975586234 62654158930 62654158997
62654711111 74553421038 74553427731 74553427798 74559066666
93333333333 93333333339 93333333395 93333333953 93333333959
93333339531 93333339598 93333395311 93333395981 93333395987
93333953114 93333959818 93333959874 93339531142 93339598189
93339598742 93395311429 93395981891 93395987429 93953114291
93959818911 93959874291 99531142911 99598189114 99598742911
187731455342 187731455900 187731455906 319755862341 319755862347
626541589302 626541589978 626547111111 745534277314 745590666666
933333333333 933333333339 933333333395 933333333953 933333333959
933333339531 933333339598 933333395311 933333395981 933333395987
933333953114 933333959818 933333959874 933339531142 933339598189
933339598742 933395311429 933395981891 933395987429 933953114291
933959818911 933959874291 939531142911 939598189114 939598742911
995311429114 995981891142 995987429114 1877314553421 1877314553427
1877314559066 3197558623417 3197558623473 3197558623479 6265415893026
6265415899786 6265471111111 7455342773145 7455906666666 9333333333333
9333333333339 9333333333395 9333333333953 9333333333959 9333333339531
9333333339598 9333333395311 9333333395981 9333333395987 9333333953114
9333333959818 9333333959874 9333339531142 9333339598189 9333339598742
9333395311429 9333395981891 9333395987429 9333953114291 9333959818911
9333959874291 9339531142911 9339598189114 9339598742911 9395311429114
9395981891142 9395987429114 9953114291142 9959818911429 9959874291142
18773145534210 18773145534277 18773145590666 31975586234177
31975586234730 31975586234797 62654158930265 62654158997865
62654711111111 74553427731455 74559066666666 93333333333333
93333333333339 93333333333395 93333333333953 93333333333959
93333333339531 93333333339598 93333333395311 93333333395981
93333333395987 93333333953114 93333333959818 93333333959874
93333339531142 93333339598189 93333339598742 93333395311429
93333395981891 93333395987429 93333953114291 93333959818911
93333959874291 93339531142911 93339598189114 93339598742911
93395311429114 93395981891142 93395987429114 93953114291142
93959818911429 93959874291142 99531142911429 99598189114291
99598742911429 187731455342103 187731455342773 187731455342779
187731455906666 319755862341777 319755862347975 626541589302654
626541589978654 626547111111111 745534277314553 745534277314559
745590666666666 933333333333333 933333333333339 933333333333395
933333333333953 933333333333959 933333333339531 933333333339598
933333333395311 933333333395981 933333333395987 933333333953114
933333333959818 933333333959874 933333339531142 933333339598189
933333339598742 933333395311429 933333395981891 933333395987429
933333953114291 933333959818911 933333959874291 933339531142911
933339598189114 933339598742911 933395311429114 933395981891142
933395987429114 933953114291142 933959818911429 933959874291142
939531142911429 939598189114291 939598742911429 995311429114291
995981891142911 995987429114291 1877314553421038 1877314553427731
1877314553427798 1877314559066666 3197558623417777 3197558623479755
6265415893026541 6265415893026547 6265415899786541 6265415899786547
6265471111111111 7455342773145534 7455342773145590 7455906666666666
9333333333333333 9333333333333339 9333333333333395 9333333333333953
9333333333333959 9333333333339531 9333333333339598 9333333333395311
9333333333395981 9333333333395987 9333333333953114 9333333333959818
9333333333959874 9333333339531142 9333333339598189 9333333339598742
9333333395311429 9333333395981891 9333333395987429 9333333953114291
9333333959818911 9333333959874291 9333339531142911 9333339598189114
9333339598742911 9333395311429114 9333395981891142 9333395987429114
9333953114291142 9333959818911429 9333959874291142 9339531142911429
9339598189114291 9339598742911429 9395311429114291 9395981891142911
9395987429114291 9953114291142911 9959818911429114 9959874291142911
18773145534277314 18773145590666666 31975586234177777
31975586234797558 62654158930265415 62654158930265471
62654158997865415 62654158997865471 62654711111111111
74553427731455342 74553427731455900 74553427731455906
74559066666666666 93333333333333333 93333333333333339
93333333333333395 93333333333333953 93333333333333959
93333333333339531 93333333333339598 93333333333395311
93333333333395981 93333333333395987 93333333333953114
93333333333959818 93333333333959874 93333333339531142
93333333339598189 93333333339598742 93333333395311429
93333333395981891 93333333395987429 93333333953114291
93333333959818911 93333333959874291 93333339531142911
93333339598189114 93333339598742911 93333395311429114
93333395981891142 93333395987429114 93333953114291142
93333959818911429 93333959874291142 93339531142911429
93339598189114291 93339598742911429 93395311429114291
93395981891142911 93395987429114291 93953114291142911
93959818911429114 93959874291142911 99531142911429114
99598189114291142 99598742911429114 187731455342773145
187731455906666666 319755862341777777 319755862347975586
626541589302654158 626541589302654711 626541589978654158
626541589978654711 626547111111111111 745534277314553421
745534277314553427 745534277314559066 745590666666666666
933333333333333333 933333333333333339 933333333333333395
933333333333333953 933333333333333959 933333333333339531
933333333333339598 933333333333395311 933333333333395981
933333333333395987 933333333333953114 933333333333959818
933333333333959874 933333333339531142 933333333339598189
933333333339598742 933333333395311429 933333333395981891
933333333395987429 933333333953114291 933333333959818911
933333333959874291 933333339531142911 933333339598189114
933333339598742911 933333395311429114 933333395981891142
933333395987429114 933333953114291142 933333959818911429
933333959874291142 933339531142911429 933339598189114291
933339598742911429 933395311429114291 933395981891142911
933395987429114291 933953114291142911 933959818911429114
933959874291142911 939531142911429114 939598189114291142
939598742911429114 995311429114291142 995981891142911429
995987429114291142
This is not in OEIS, and probably should remain not in it.
The command "cal -R 1/1/1 <year>" for any year before 10000 should
show the Gregorian calendar for that year. (Except the year 1, which
has a bug.)
Here is my very short C program which generated the above.
Have fun figuring out how it works.
#include <stdio.h>
int main() {
long long i,j,k,p,y,c[400],h[1000];
c[0] = 7; i = 2;
for (j=1;j<400;j++) {
c[j] = (c[j-1] + i) % 7; i = 1;
if ((j%4 == 0) && (j%100 != 0)) { c[j] += 7; i = 2; }
}
for (j=0;j<9;j++) h[j] = j+1;
p = 9; y = 0;
for (j=0;(j<p) && (y < 1000000000000000000);j++) {
for (k=0;k<10;k++) {
y = h[j]*10 + k;
if (c[y%400] == c[h[j]%400]) { h[p++] = y; printf("%lld\n",y); }
}
}
return(0);
}