Java only Rajesh loves lucky numbers. Everyone knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, the numbers 47,744, 4 are lucky and 5, 17,467 are not. Let Fa(x) equal the number of digits d in the decimal representation of the positive integer x. Chef is only interested in F4(x) and F₂(x) functions. For a given positive integer N, he wants to know the total number of distinct pairs (L; R) such that F4(L) + F4(L + 1) + ... + F4(R) equals F7(L) + F7(L + 1) + ... + F7(R) and 1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question
Java only
Rajesh loves lucky numbers. Everyone knows that lucky numbers are positive integers whose
decimal representation contains only the lucky digits 4 and 7. For example, the numbers 47,744, 4
are lucky and 5, 17,467 are not.
Let F(x) equal the number of digits d in the decimal representation of the positive integer x. Chef is
only interested in F4(x) and F7(x) functions. For a given positive integer N, he wants to know the total
number of distinct pairs (L; R) such that F4(L) + F4(L + 1) + . + F4(R) equals F7(L) + F7(L + 1) + + F7(R)
and 1 <L<R<N.
***
Input
1
10
Output
31
Transcribed Image Text:Java only Rajesh loves lucky numbers. Everyone knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, the numbers 47,744, 4 are lucky and 5, 17,467 are not. Let F(x) equal the number of digits d in the decimal representation of the positive integer x. Chef is only interested in F4(x) and F7(x) functions. For a given positive integer N, he wants to know the total number of distinct pairs (L; R) such that F4(L) + F4(L + 1) + . + F4(R) equals F7(L) + F7(L + 1) + + F7(R) and 1 <L<R<N. *** Input 1 10 Output 31
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Hiring Problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning