1

Given a range of hexadecimal numbers, how do I determine the total number of them that do not look like decimal numbers?

Background: I'm designing a system that auto-generates IDs that consist of four digit hexadecimal numbers but I want to exclude those that looks like decimal numbers so that users are not confused. I only want to know that with that restriction, how many IDs can the system generate (and decide if I need to increase the number of digits or not).

N.B. I can easily detect if a hexadecimal number looks like a decimal number or not though.

Najib Idrissi
  • 54,185
Lukman
  • 263
  • I've taken the liberty of creating and adding the tag hexadecimal. Incidentally, http://codegolf.stackexchange.com/ might enjoy this problem. – Travis Willse Jan 04 '16 at 04:14
  • If the given range is just the set of nonnegative hexadecimal numbers of $n$ digits, including leading zeros, then the number of hex numbers in which only the digits $0, \ldots, 9$ occur is $10^n$, and so the number of hex numbers excluding these is $16^n - 10^n$. For $n = 4$ this is $55536$. – Travis Willse Jan 04 '16 at 04:18
  • 3
    and DEAD or BEEF would not confuse users? – Déjà vu Jan 04 '16 at 04:21
  • Sorry, what if there's no leading zero. – Lukman Jan 04 '16 at 04:21
  • Why would there be a tag "hexadecimal"? Do we also need tags for "decimal", "binary", "octal", "base-12345", etc? The tag "number-systems" is quite sufficient. – Najib Idrissi Jan 05 '16 at 14:11

1 Answers1

2

Number of numbers with at least an hex letter (a to f) as Travis commented $$16^{n} - 10^{n} = 55536$$

Number of numbers with no decimal at all (a to f only) $$6^{n} = 1296$$

Number of numbers with at least an hex letter (a to f) with no leading zero $$16^{n} - 10^{n} - 16^{n-1} + 10^{n-1} = 52440$$

Déjà vu
  • 934