Skip to content

Instantly share code, notes, and snippets.

@ryuheechul
Last active January 20, 2019 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryuheechul/e0cc4347fb5f505f4aac452e51589b20 to your computer and use it in GitHub Desktop.
Save ryuheechul/e0cc4347fb5f505f4aac452e51589b20 to your computer and use it in GitHub Desktop.
Something special about the number 36

I just turned age 36 (by Korean standards) and noticed that some of my friends seem to be sad to have such a "big" number as their age.

So I thought about whether there could be anything special about the number 36 and I found a simple and interesting pattern for that number.

When you divide 36 by 2, the answer is 18 (36 / 2 == 18); and when you multiply each digit of 36 individually, the answer is also 18 (3 * 6 == 18)!

So it seemed kind of special to me and then I wondered if there is any natural number that has these same features (except 0)

As a non-math person, the shocking discovery was that 36 seems to be the only number under 10M.

function digits(n) { 
  if (n < 10) { 
    return [n] 
  }
  
  return digits(parseInt(n / 10))
    .concat(n % 10) 
}

assert(JSON.stringify([7, 8, 9, 4, 5, 6]) === JSON.stringify(digits(789456)))
// test digits function

function findThatNumber(rangeTo){
  return [...Array(rangeTo).keys()]
    .map((n) => [n / 2, digits(n).reduce((x, y) => x * y, 1)])
    .filter(([x, y]) => x == y)
    .map(([x]) => x * 2)
}

findThatNumber(100)
// [ 0, 36 ]
findThatNumber(1000)
// [ 0, 36 ]
findThatNumber(10000)
// [ 0, 36 ]
findThatNumber(100000)
// [ 0, 36 ]
findThatNumber(1000000)
// [ 0, 36 ]
findThatNumber(10000000)
// [ 0, 36 ]

The last one took 40 seconds on my Mac Mini so I stopped there for now.

Maybe I will keep discovering more special things about the number 36 from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment