Given two integers N and D, the task is to find the value of F(N) where the value of F(1) is D, where F(K) is given as:
Input: N = 3, D = 487
As F(1) = 487,
F(2) = 487 * (maxDigit(487) – minDigit(487)) = 487 * 4 = 1948
F(3) = 1948 * (maxDigit(1948) – minDigit(1948)) = 1948 * 8 = 15584
Input: N = 5, D = 487
Approach: The idea is to compute the value of F(2) to F(N) iteratively with the help of the loop. Also, the maximum and minimum digits in each number can be computed using the help of the loop by dividing the number by 10, Simultaneously taking the modulo to get the digit.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Number formed by adding product of its max and min digit K times
- Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
- Min-Max Product Tree of a given Binary Tree
- Nth term of given recurrence relation having each term equal to the product of previous K terms
- Min steps to convert N-digit prime number into another by replacing a digit in each step
- Partition N into M parts such that difference between Max and Min part is smallest
- Divide a sorted array in K parts with sum of difference of max and min minimized in each part
- Min and max length subarray having adjacent element difference atmost K
- Count of N-digit numbers having digit XOR as single digit
- Number of odd and even results for every value of x in range [min, max] after performing N steps
- Sum of width (max and min diff) of all Subsequences
- Find Nth term of the series where each term differs by 6 and 2 alternately
- Multiplication table till N rows where every Kth row is table of K upto Kth term
- Find the value of max(f(x)) - min(f(x)) for a given F(x)
- Remove minimum elements from the array such that 2*min becomes more than max
- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- First term from given Nth term of the equation F(N) = (2 * F(N - 1)) % 10^9 + 7
- Pair with min absolute difference and whose product is N+1 or N+2
- Find nth number that contains the digit k or divisible by k.
- Program to delete Nth digit of a Number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.