Birthdate Magic Number

This week I was teaching my daughter the concept of a “birthdate magic number”. It was a way to get her thinking about math and algorithms. And also to keep her busy – she was bored. In any case, the concept of a “birthdate magic number” also known as BMN, doesn’t formally exist, but it was rather fabricated, as far as I’m aware. BMN was defined as being the following:

1.  Take your birthdate, in the format MMDDYYYY
2.  Read it as a number N, so N = Number(MMDDYYYY)
3.  Now if N has only a single digit, N is your BMN
4.  Otherwise make N = SumDigits(N) and go back to step 3

An example is ideal here. Take a random birthdate, say 03/14/15 (totally random!). In such a case the format should be 03142015. Hence N = 3142015 (as a number). Great, now we land at step #3. Not a single digit. Step #4, N becomes 3+1+4+2+0+1+5 = 16. Not a single digit. N then becomes 1+6 = 7. Single digit. BMN(03142015) = 7.

She got it, was excited and start calculating the BMN for the members of our family (we did it for 6 people). The distribution was:
a)  3 of them had BMN = 1
b)  2 of them had BMN = 8
c)  1 of them had BMN = 5

Now, granted, the two that had BMN = 8 came off of twins, hence that’s sort of expected. But other than that, the distribution was heavily skewed towards 1 (75%). So the question became: what’s the distribution of BMN out there, in the wild, for all the dates (A.C.)? Are they skewed too? If so, skewed towards which number? Which BMN is the utterly special one? Would that be 1? 3? Zero? (well zero was impossible, we figured that in 1 sec).

So we open visual studio, and we (actually I) wrote the following program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace MagicNumbersHistogram
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime date = new DateTime(1, 1, 1);

            int total = 0;
            Hashtable htHistogram = new Hashtable();
            while (date <= DateTime.Now)
            {
                long number = Convert.ToInt64(date.Month.ToString() + date.Day.ToString() + date.Year.ToString());
                long magicNumber = MagicNumber(number);
                if (!htHistogram.ContainsKey(magicNumber))
                {
                    htHistogram.Add(magicNumber, 1);
                }
                else
                {
                    htHistogram[magicNumber] = (int)htHistogram[magicNumber] + 1;
                }

                date = date.AddDays(1);
                total++;
            }

            foreach (long magicNumber in htHistogram.Keys)
            {
                Console.WriteLine("MagicNumber[{0}] = {1} ({2}%)", magicNumber, (int)htHistogram[magicNumber], (((int)htHistogram[magicNumber]*100.0) / total).ToString());
            }
        }

        static long MagicNumber(long n)
        {
            if (n >= 0 && n <= 9)
            {
                return n;
            }
            else
            {
                long sum = 0;
                while (n > 0)
                {
                    sum += (n % 10);
                    n /= 10;
                }
                return MagicNumber(sum);
            }
        }
    }
}


When we ran it, the output was this:

MagicNumber[9] = 81739 (11.1112470467972%)
MagicNumber[8] = 81740 (11.1113829824833%)
MagicNumber[7] = 81739 (11.1112470467972%)
MagicNumber[6] = 81737 (11.110975175425%)
MagicNumber[5] = 81736 (11.1108392397389%)
MagicNumber[4] = 81736 (11.1108392397389%)
MagicNumber[3] = 81738 (11.1111111111111%)
MagicNumber[2] = 81738 (11.1111111111111%)
MagicNumber[1] = 81739 (11.1112470467972%)

Hence, the distribution of BMNs is actually precisely and irrefutably the same! Kind of expected… maybe not?... Actually not expected. Not at all – why would it be?

With Love,
Marcelo

Comments

  1. There seems to be a similar concept in numerology, but they keep the year/month/date separate. Check out http://healing.about.com/od/numerology/a/birth-path-numerology-formula.htm

    I am guessing the answer to whether this is expected depends on the numbers that the years themselves condense down to. The dates and months will repeat themselves in each year as it is. Interesting food for thought...

    ReplyDelete
  2. Thx Amitava, indeed they repeat themselves (months and days), but i couldnt prove the even distribution mathematically.

    ReplyDelete

Post a Comment

Popular posts from this blog

Changing the root of a binary tree

ProjectEuler Problem 719 (some hints, but no spoilers)

The Power Sum, a recursive problem by HackerRank