Associated Topics || Dr. Math Home || Search Dr. Math

Dates that Read the Same Backwards and Forwards

```Date: 02/02/2010 at 01:46:19
From: Hugh
Subject: Arithmetic series for Calender Palindrome

Hello,

I am interested in figuring out if the the following calendar
palindrome can be represented by an equation:

Today is February 1st, 2010, which some parts of the world represent
as 01/02/2010.  What is the arithmetic series for all palindromes
like this?

I don't even know if this could be considered an arithmetic series.
This is something I'm thinking about and not sure even if the
question makes sense.

I'm sorry I don't have anything to show, except for listing the
occurrences in this century.  I seriously don't even know if this is
a legitimate question.  But I am really curious if it is possible!

Maybe you could at least let me know if it is a legitimate question;
and if it is, set me off on the right path?

Thanks.

```

```
Date: 02/02/2010 at 10:41:45
From: Doctor Carter
Subject: Re: Arithmetic series for Calender Palindrome

Hi Hugh -

Thanks for sending this nice question to Dr. Math!

There will be 366 dates which are palindromes, 2092 being a leap
year.  Given any two-digit day of the month (Dd) and any two-digit
month of the year (Mm), you can always construct the palindrome; it's
Dd/Mm/mMdD.

One approach to generating the palindromes is to list the 4-digit
numbers DdMm which are legitimate date prefixes.  I can't do this as
a simple arithmetic sequence, but I can do it using integer
arithmetic, which is not much more complicated.

Here's a little C code which does it:

--------

#include <stdio.h>

int main()
{
int i, d, m, dd, mm;

for ( i=1; i<=366; i++ )
{
d  = i+93;
m  = (5*d - 9)/153;
dd = d - (153*m + 8)/5;
mm = m - 12*(m/13);

printf( "%04d
", 100*dd+mm );
}
}

--------

If you try this, you'll notice that date prefixes for January and
February come last.  That's a "feature," not a bug!

If you want to understand where this code comes from and why it
works, take a look at the excellent discussion of date arithmetic
given by Dr. Vogler here:

http://mathforum.org/library/drmath/view/66535.html

I hope you find this interesting.  Thanks again!

- Doctor Carter, The Math Forum
http://mathforum.org/dr.math/

```

```
Date: 02/02/2010 at 12:06:55
From: Hugh
Subject: Arithmetic series for Calender Palindrome

Doctor Carter,

Thank you very much for your response.

I put the code into Excel to see how it works, but I do not know what
%04d means in your print statement.  I read the article that you
linked to, and though I now understand the use of "153," I still
don't understand where the "93" comes from.  In fact, I do not
understand the lines of the code you wrote.  Could you explain how
you formulated each line?

Thanks again for your help, and I hope to hear from you soon.

Hugh

```

```
Date: 02/02/2010 at 14:01:35
From: Doctor Carter
Subject: Re: Arithmetic series for Calender Palindrone

Hi -

And you're welcome!

As you learned in the other article, it's convenient to number the
months from 03 (March) to 14 (February).  Day number 94 in the
numbering corresponds to March 1.  The day numbers that come earlier
have the following "interpretations":

-  1 corresponds to day 0 of month 0.  Month 0 has 31 days, but it
does not correspond to December

-  33 corresponds to day 1 of month 1.  Month 1 has 30 days the way
things are computed, so it certainly cannot correspond to January

-  63 corresponds to day 1 of month 2.  Month 2 has 31 days (it's not
February!)

-  93 corresponds to day 31 of month 2 (not February)

The first value of day number d considered in the code is therefore
94, which corresponds to day 1 of month 3.  And month 3 *does*
correspond to March.

The two lines of code ...

m  = (5*d - 9)/153;
dd = d - (153*m + 8)/5;

The next line, mm = m - 12*(m/13), is renaming months 13 and 14 to
months 01 and 02 -- calling January and February by their proper
numbers, in other words.

The final line, printf( "%04d", 100*dd+mm ), is to print the number
100*dd+mm.  The black magic inside the double quotes is what's called
a "format" -- we're telling the computer to interpret (100dd + mm) as
a whole number base 10 (that's the d); to use 4 spaces to print it
(the 4); to print any leading zeros (that's the 0); and to generate a
new line character afterwards (the space).

Have fun trying this out in Excel -- but be sure to do all divisions
with truncation!  In other words, round the result of any division
*down* to a whole number; it won't work otherwise.

There are several different algorithms around for determining the
number of elapsed days between two calendar dates; I'm using Dr.
Vogler's, but there are others.  You'll find additional discussion at

http://en.wikipedia.org/wiki/Julian_day

In particular, take a look at the section named "Calculation."

Best wishes -

- Doctor Carter, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
High School Calculators, Computers
High School Discrete Mathematics
High School Number Theory
High School Puzzles

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search