Given two integers N and X. Make a number in such a way that the number contains the first and last digit occurring in .
Input : N = 10, X = 5 Output : 1010101010 Explanation : 10^1 = 10 10^2 = 100 10^3 = 1000 10^4 = 10000 10^5 = 100000 Take First and Last Digit of each Power to get required number. Input : N = 19, X = 4 Output : 19316911 Explanation : 19^1 = 19 19^2 = 361 19^3 = 6859 19^4 = 130321 Take First and Last Digit of each Power to get required number.
Recommended: Please solve it on “PRACTICE“first, before moving on to the solution.
1. Calculate all Powers of N from 1 to X one by one.
2. Store the Output in power array.
3. Store power i.e, last_digit and power[power_size – 1] i.e, unit_digit from power array to result array.
4. Print the result Array.
Below is the implementation of the above approach :
- Count of numbers whose sum of increasing powers of digits is equal to the number itself
- Minimum number of given powers of 2 required to represent a number
- Representation of a number in powers of other
- Check if a number can be represented as sum of non zero powers of 2
- Find smallest number with given number of digits and sum of digits under given constraints
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Number of triangles possible with given lengths of sticks which are powers of 2
- Balance pans using given weights that are powers of a number
- Sum of first N natural numbers by taking powers of 2 as negative number
- Sum of largest divisible powers of p (a prime number) in a range
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Find the Largest number with given number of digits and sum of digits
- Find the average of k digits from the beginning and l digits from the end of the given 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.
Improved By : manishshaw1