TopCoder problem "TheAlmostLuckyNumbers" used in SRM 453.5 (Division I Level Three)



Problem Statement

    A lucky number is a number whose decimal representation contains only the digits 4 and 7. An almost lucky number is a number that is divisible by a lucky number. For example, 14, 36 and 747 are almost lucky, but 2 and 17 are not. Note that a number can be both lucky and almost lucky at the same time (for example, 747).



You are given longs a and b. Return the number of almost lucky numbers between a and b, inclusive.
 

Definition

    
Class:TheAlmostLuckyNumbers
Method:count
Parameters:long, long
Returns:long
Method signature:long count(long a, long b)
(be sure your method is public)
    
 

Constraints

-a will be between 1 and 10,000,000,000, inclusive.
-b will be between a and 10,000,000,000, inclusive.
 

Examples

0)
    
1
10
Returns: 3
There are three almost lucky numbers less than or equal to ten - 4, 7 and 8.
1)
    
14
14
Returns: 1
14 is an almost lucky number.
2)
    
1
100
Returns: 39
3)
    
1234
4321
Returns: 1178

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10420

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14174&pm=10420

Writer:

Vasyl[alphacom]

Testers:

PabloGilberto , ivan_metelsky , Xixas

Problem categories:

Recursion