Given a range [L, R]. The task is to find the total number of Hexadecimal alphabets that are required to write every number in the range.
Hexadecimal alphabets are the alphabets in the range [A, F] which are required to represent decimal numbers from the range [10, 15]
Input: L = 10, R = 15
All the numbers from 10 to 15 contain a hexadecimal alphabet.
Input: L = 15, R = 16
15 and 16 are represented in hexadecimal as F and 10 respectively.
- First of all, check if num ≥ 10 and num ≤ 15. If yes then increment the count as decimal numbers from 10 to 15 contain a hexadecimal alphabet.
- If num > 15 than update the number as num = num % 16. If it is greater than 10 than increment the count.
- Repeat 2nd step till number (for every number) is greater than 0.
Below is the implementation of the above approach:
- Check if a HexaDecimal number is Even or Odd
- Convert a binary number to hexadecimal number
- Program to Convert Hexadecimal Number to Binary
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Program for Hexadecimal to Decimal
- StringStream in C++ for Decimal to Hexadecimal and back
- Program to convert IP address to hexadecimal
- Program to Convert Hexadecimal to Octal
- Program for decimal to hexadecimal conversion
- Hexadecimal equivalents in Binary Valued Graph
- Largest and Smallest N-digit Hexadecimal Numbers
- Count Number of animals in a zoo from given number of head and legs
- Find count of digits in a number that divide the number
- Convert Hexadecimal value String to ASCII value String
- Count number of even and odd elements in an array
- Count the number of 1's and 0's in a binary array using STL in C++ ?
- C program to Count the digits of a number
- Count the number of holes in an integer
- Count the number of clumps in the given Array
- Count number of even and odd length elements in an Array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.