A friend of mine believes a lot in fate n all. He thinks 4 and 7 are lucky digits, and all other digits are not lucky. He has a definition for lucky numbers as well. A lucky number is a number that contains only lucky digits in decimal notation. All others are unlucky as per him.
He wants to know how many lucky numbers are there between two given numbers. I want u all to help him in this.
The input consists of several test cases. Each line of a test case consists of two numbers separated by a space: a and b. Both the numbers will be between 1 and 1,000,000,000, inclusive.
For each input line, determine the number of lucky numbers between a and b, inclusive.
static void Main(string args)
int a = 1000000;
int b = 5000000;
int count = 0;
for (; a <= b; a++)
string str = a.ToString();
int flag = 0;
for (int i = 0; i < str.Length; i++)
if (str[i].ToString() != "4")
if (str[i].ToString() != "7")
flag = 1;
if (flag == 0)
Console.WriteLine("Number of lucky numbers = " + count.ToString());